How to make an automatic Diagonal move


I’m new on Gdevelop, and I’m trying to make a fireball move in diagonal.
I’ve almost manage to do it, but my animations doesn’t work.

I don’t understand why. I tried to put my animation in another condition, but now it’s only the “look right” that doesn’t work.

Have someone an explication for it?
Thank you a lot !

In english maybe it’s better :smiley:

Well first of all, you should use the trigger once condition on all the events that change the animation of the FireBall sprite. You normally don’t want to be change the animation ever frame (that’s what it’s doing right now).

You should also remove the second event that checks for collision between FireBall and GroupeDecor. Before that, move the sub events from the second event that checks for collision to the be under the first one as sub events. You do not need two events that check the same collision when you can just have one.

I saw you were talking about moving the object in a diagonal direction; To do this, you would just apply the same amount of force in, for example, the right direction (positive x force) and the up direction (negative y force) and this would making it go diagonally right. You may notice that when the object is moving diagonally it is going faster than moving straight; to fix this you can use the normalize(number to normalize, min, max) function to normalize the speed between a min and max to 0 and 1 (I may be wrong so don’t quote me on this).

If you are trying to get top down movement or make what you are trying to do easier, you should put the top-down character behavior on the fireball and disable the default controls. This behavior has 4-way movement and 8-way movement (this would suit your needs). You can simulator a control when the fireball collides, for example, you can simulate the up and right controls to make it go diagonally right.

Thank you a lot ! I didn’t think to disable the topdown character behavior, so I can use the 8-way movement.
I did the two same conditions just to try where the “bug” were. But I didn’t know that the animation changed every frame.

I’ll try your advices, thank you again.

No problem! Feel free to DM me on discord if you have any further questions cnem#2156.

1 Like