Direction of the touch on mobile

I have a spirit that changes its image based on the direction it moves (left right up down). I want to do that on mobile. when user touch it moves to the touch point but i want to know which direction it will move to change the spirit image according to that. How I can do that

You can get the touch position (with MouseX() and MouseY()) so you can add a force to the player to move to this position.

For the angle you’ll have to use math, specifically “atan2”:

Do = ToDeg(atan2(MouseY() - Player.Y(), MouseX() - Player.X())) to the variable "angle"

This will save the angle between the player and the cursor in a variable, now you can check this variable value to set the animation:

Conditions: Variable "angle" is >= 45 Variable "angle" is < 135 Actions: Set animation of Player to "down"
The same for other directions. You can add a text object to display the value of the angle variable in case you aren’t sure about the values to test :slight_smile: