Length of animation

Hi guys,

How can I simply set how many times an animation should run, for example 3 times?
I searched in the forum, but I couldn;t find a simple explanation.

Kind regards,

If animation ended and variable animationTimes < 3 replay animation and add 1 to variable animationTimes.

Hi Arthuro555,

thanks for your quick reply.
I am a newbie with Gdevelop. So I have trouble understand where to put the piece of information you just gave me. I thought the solution would be much easier. like …run animation of object
3 times. So which part of the solution you gave me should go into the “condition section”, and which part into the “action” section ?

So, at a high level, you cannot “just” set an animation to only run 3 times.

What Arthuro is mentioning is the idea of “Only play the animation if a specific condition is met”. In the event, you’re setting that condition of “This “somevariablename” variable is less than 3”. The action in the event would be both “play animation” AND “Increase “somevariablename” by 1”

You’ll also probably want to add a “if animation is complete” condition in there as well.

If you’re unclear on conditions and actions, I strongly recommend going through the first 3 tutorials here: GDevelop 5 tutorials [GDevelop wiki]

Additionally, read up on variables here: Variables [GDevelop wiki]

and events here: Events [GDevelop wiki]

The example below uses the frames of the animation to replay it. When the animation gets to the last frame 5 it goes back to frame 0. Then in the action field it adds 1 to a variable which I called “repeat”. The condition field keeps checking that the variable “repeat” is less than or equal to 3. When that variable reaches 4, it stops repeating the animation.

1 Like

Hi Gorguruga,

thank you for your advice.
I was busy and I totally forgot to reply.

1 Like

Hi Silver-Streak,

I am busy learning with the document links you gave me.
Sorry for my late response.