Play an animation only once every X

Kinda lost

So I have a simple project I’m using to play around with Gdevelop, in this scene I’ve got a portal from which the player emerge in the start of the scene and when he dies:

It works quite well, once the scene starts the player spawn and when he’s out of bounds respawn in the same point. It also plays once the player is first spawned, but I can’t replay the animation once the character is out of bounds.

Here is the visual script (it’s linked to the main scene):

Hi, dumb question but I’m not clear, is it the animation for the portal or the character that is not replaying? Also, if there is not a particular reason you used ScreenHeight(), you may want to change it to SceneWindowHeight() because it can cause some weird issues if the player resizes the screen later on, but the scene window call seems to prevent these. Just speaking from some hair-tearing personal experience :slight_smile:

Hi terto and welcome!

I think you’re asking why isn’t the checkpoint animation playing. This might also be a stupid suggestion, haha, But is it possible that it is playing but the redhero is in front of it because of the z order and you can’t see the animation? If so, you could change the z order and maybe the order of the actions as well.

Also, you can set redhero’s new position with just one action - Position and specify x and y together.

Looking at it further, and assuming its the portal anime, it is activating when the playerY>than screenheight. But you move the player first, so it is no longer playerY> screen height, so the condition is no longer true, so I believe this is what makes it not play, because the condition is not true anymore.
What you could do is try triggering the animation first in the sequence, then move cahracter pos, or if the anime is too short, when the character cahnges pos, set a variable like variable portal=1. Then do another event when variable portal=1, the animation plays, then resets to variable portal=0 after the animation is finished.

Or, just another suggestion, but terto, have you set the animation to loop like this:


snobunni, I tested terto’s event the way it is, and the animation did play for me.

1 Like