How to move using the rotation to make out what way to move? [solved]

i’m making a tank game for the mobile.
i did already let it move up and down, turn left and right.
my problem is if it turns left and right, it still does go up and down…

Hi, first of all, whenever rotation is important, your sprite has to be aligned horizontally by default (meaning at the time when you load it into the engine) - the front part in the east and the back in the west: Basic game making concepts - What you need to know to start with GDevelop - GDevelop documentation

Btw. there is a behavior for top-down-movement with rotation that could be helpful: Top-Down Movement behavior - GDevelop documentation

i think this can fix it.

it does rotate when it is moving… this is also interesting to work with, but i have no way to know when it is rotating or when it is moving… so i cant add animations to this… does anyone know a way to rotate the angle of movement when rotating the tank in my game?

The y() coordinate goes from top to bottom. If you want the object to move in the direction it’s facing then you can apply either an immediate or permanent force in the angle the sprite rotated. Just remember, angle zero faces to the right. So, the sprite should be drawn facing that direction.

Here’s an example using a joystick and an object named soldiers. It uses an instant force meaning it only move while the action is triggered.

1 Like

it works! thanks for your help.

1 Like

dont know how to close a topic… can someone help?

You’re welcome. To mark as solved. You edit the title and add [solved]

click the little pen
image

1 Like

Just edit the topic name, put “[SOLVED]”, you should keep the topic alive so others with your problem can see this.

1 Like

thanks for the information

1 Like