Ask here your questions to get help using GDevelop.
By robert20
#69249 Hi,

I have this object with top down movement behavior, the thing is I set up simulated keys "WASD" for W- goes up A- goes right, and such.

The thing is , I actually need " tank controls" like, W goes forward, S goes backwards and A and D should rotate the tank, any of you have tips on how to achieve this?

Thanks!
Last edited by robert20 on Sat 8 Dec 2018, 07:03, edited 1 time in total.
User avatar
By Lizard-13
#69257 The top-down behavior doesn't support relative directions, you'll have to write the code yourself, it would be something like:
Code: Select allConditions: Key W is pressed
Actions: Add a force to Tank, angle: Tank.Angle(), length: 200, damping: 0

Conditions: Key S is pressed
Actions: Add a force to Tank, angle: Tank.Angle() + 180, length: 100, damping: 0

Conditions: Key A is pressed
Actions: Rotate Tank at -45 degrees/second

Conditions: Key D is pressed
Actions: Rotate Tank at 45 degrees/second
User avatar
By MeX1Co
#69259 Also to make it a bit more realistic and not have it turn when it is not moving at all you should add a condition that when speed (or sum of forces on the tank) is > 5 then do the A and D conditions that Lizard said...
By robert20
#69294 Ok, this works perfect for the tank, but, My tank is compossed of a tank and a turret that roates following the mouse, so, using this code you sent me the turret moves in the direction of the mouse instead of the direction of the tank I'll see if I can fix it and report.

UPDATE: I fixed it, simply by applaying the force using the angle of the tank, Thank you so much, this makes it perfect!!!