# How do I set bullet moving angle to left analog stick?

0 favourites
• 8 posts
From the Asset Store
This is a twin stick shooter similar to Enter the gungeon,Nuclear Throne, Helldivers & Soul knight for the mobile device
• Hi.

I'm trying to figure out how to set the moving angle of my spawned bullets to shoot in the direction the left analog is facing when I shoot. I can't get it to work properly. Does anyone here know how to achieve this simple task?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• This question has come up a few times on these forums lately, it seems.

To find the angle of the left analog stick you can use this expression.

Then you just need to set On created - Set Bullet angle to *the code above*

That [i]should[/i] work for you.
• ryanrybot Wow, that works great. Thank you so much! What is the logic behind this sorcery? And can I lock it so it just goes in 4 or 8 directions?

I have to learn to do this stuff on my own. But couldn't figure it out.

• angle(X1,X2,Y1,Y2) finds the angle "between" two points (mathematically incorrect definition, but works for us).

So you have an angle value that's between 0 and 360 - if you want to have 4 directions just divide by 90, round, then multiply by 90. For 8 directions use 45.

• Somebody I see, now I understand how to do all of this. Thank you!

One last question. Now my crosshair follows the analog stick. But when I stand still after running left my character is facing left but the crosshair jumps back and faces right. Do you know how to keep the crosshair at the same angle as the character when the analog stick is not in use?

[attachment=0:boiwvlwc][/attachment:boiwvlwc]

• If it jumps back then it's probably due to the sticks generally being a little imprecise (either plain value shifts or a heavy thumb)...

EDIT: Oh, turns out C2 already has a deadzone check - right in the Gamepad object settings. Maybe see if yours is high enough?

I guess then you need a check for non-zero values - otherwise at 0,0 the angle will always be 0, thus facing right.

[IGNORE EVERYTHING BELOW] - games usually have a "deadzone" so you might want to put in a little check, like:

Gamepad.Axis(0, 0) is between values -ZZZ and ZZZ <== Some value here - I don't know what the value range for the gamepad is, maybe it's 0-1, then something like 0.05 might do, maybe it's a more usual 255, either way you could probably check debug to see the values.

OR

Gamepad.Axis(0, 1) is between values -ZZZ and ZZZ

DO THE ANGLE THING.

• Somebody Awesome, thanks. I solved it by checking if the axis of the analog stick was 0 and the character is mirrored then mirror the crosshair else not mirror

• Hi Anonnymitet! I'm glad that worked for you!

There is absolutely no harm asking. In fact I asked this very question a couple weeks ago, which is why I knew the answer.

• 8 posts