I’m working on this project where a character is going toward the mouse when you click.
I need to set one of the 4 animations according to the direction the character is going so I use the “AngleBetweenPositions” function to get it.
Can you help me figure out how it works ? Thanks.
Link to my project : https://games.gdevelop-app.com/game-acc85d60-7030-4c15-acdd-910153631b8a/index.html
My guess is that you need to ensure that your call to MouseX() and MouseY() pass in the layer that corresponds to the layer of your character object.
Other than that you may want to modify first two arguments to be:
AngleBetweenPositions(Alex.X() + Alex.Width() / 2, Alex.Y() + Alex.Height() / 2, MouseX(AlexLayer), MouseY(AlexLayer))
Ok I guess it’s a good idea to check if my mouse coordinates relates to the good layer. But I don’t understand what you mean by “AlexLayer”. Are the parenthesis role are to situate a position for the layer ?
It’s strange because in my project build you can see the variable change according to the mouse position. For example if you put your mouse at the left or the right of the character the number doesn’t change the same.
EDIT : You’re referring to the mouse coordinates. In my project, I referenced the position of the image following the mouse wich is called mouse, that’s why I didn’t understand the value of the parenthesis. My bad
Btw it works now.