# Strafe

0 favourites
• 13 posts
• I'm working on a helicopter game and thought it would be cool to add the ability to strafe left and right.

I'm not totally sure how to do this since it will depend on the angle the chopper is currently at as to how the x,y will change. Is there a math equation that does this anywhere?

Thanks :)

Ed

• ## Try Construct 3

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

Construct 3 users don't see these ads
• In short:

for x position you need to refer to Cos(heli.angle)

and for y position: Sin(heli.angle)

Sin and Cos basically generate a number between 1 and -1 depending on the angle given.

https://dl.dropbox.com/u/53374990/helirelative.capx

• Thank you.

• wut.. :S can anyone else try the link and confirm that?

• Weird, was just a chrome thing. Worked fine in firefox.

• Confirmed - 404 (as above).

• OK, thanks for that. But what if I don't want it to rotate while strafing, but just continue on the straight path? Not sure if I am making sense.

• hmm not sure If i know what you mean..

just to check, you are aware that the helicopter faces the direction of the mouse, right?

• Yeah, right now I am not using the mouse to control. I'll try it that way and see. Thanks.

I was thinking of having a strafe left and strafe right button, but this might be better :)

• The reason being is chopper can spin around as fast as you can move the mouse. Thank you though, this was all very helpful

• If you do decide to use the mouse I think the best way to do it would be to make the helicopter move simply camera-relative.. (where pressing up/down/left/right will always move the helicopter in that direction relative to the screen, regardless of the helicopters angle)

Also, you can smooth out and limit the rotational speed in a similar way you smooth out directions and limit their move speed.

Instead of setting the heli's angle to the mouse, set a variable 'targetangle' to the mouse... and have the heli.angle move towards that gradually using one of ..many.. methods..

• Awesome, thanks so much :)

• 13 posts