Path Finding Behavior

Hello to all,
I am studying the pathfinder; I’m testing the tank example but can’t understand one thing:
How does the tank rotate? In the example I see Animation 0 with many lines.
I suppose Gdevelop automatically uses the correct animation based on the rotation.
I question: Is it correct?

II question: how to create a multiple line in an animation? I do not understand.


Thank you,

You cannot do that, it’s something from gd4 that is still in the code but should not be used anymore (it’s deprecated). Just use other animations.

1 Like

Good to know, I remember wondering about that.

It is indeed from GD4. The example is using something called an “8 Directions” animation.

This type is missing from the “new” GD5 IDE but since GD5 uses the same core as GD4, it still works even though it looks weird in the IDE.
I’m not sure if this animation type was deprecated I guess it was only forgotten, I think it should be possible to be added to the new IDE, the core has the feature it is only missing from the IDE.

Thanks a lot to all.
So, can you please suggest me an alternative event to manage the change animation on change of the direction ?

With the 8 Directions Animation out of the picture, currently there is no predefined way to implement this.
You need to use common sense.

One way to do it for example is to add each direction as an individual animation:

Animation 0 Up
Animation 1 UpRight
Animation 2 Right

Then you can for example check the angle or the key press of the player to change animation.

If W key is pressed and D key is NOT pressed Do = 0 to Animation
If D key is pressed and W key is NOT pressed Do = 2 to Animation
if W key is pressed and D key is pressed Do = 1 to Animation

And you can do something similar by comparing the Angle of the sprite but in order for this to work you need to make sure you check the box in in the path finding behavior to rotate object as it moves on the path.

So then you can say for example:

If Angle > 350 and < 10 Do = 2 to Animation
If Angle > 300 and < 350 Do = 1 to Animation

Obviously you need to experiment with the values.

In case anyone interested I have uploaded a modified version of this example demonstrating how to do it manually by comparing Angle value here:

As always, you can find the download at the bottom of the list :+1:


Thanks, you use tankNode and tank. Two differente objects. You are a genious !!!