Jumping animation loop

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sora1412

Hey, So I just started game dev using godot recently and I’m currently making a simple 2d platformer with animatedSprites. and of course there’s a jumping animation

so my problem is in my sprite the jumping animation consist of 5 frames from the character launching to character tucking in midair. So I use all 5 frames and apply the animation when the player press jump on their keyboard. However I notice that if the character is still mid air and the jumping animation is done it will loop the animation back making it awkward, how can I overcome this? is there some sort of way to prevent the animation from looping?

 if (IsOnFloor())
        if (Input.IsActionJustPressed("jump"))
            velocity.y = -jumpHeight;
            isInAir = true;

            isInAir = false;
        IsDashAvailable = true;
        canClimb = true;

I’m using C# as the language

:bust_in_silhouette: Reply From: Gluon

If you go to the editor where you add the animations, underneath where you see a list of the names of the animations on that animatedsprite2d you will find a “loop” option. You can turn that too off to stop it from looping the animation.

There is also a set loop code you can use if you prefer to do it in code rather than the editor;


value is true for looping and false for not looping.

Gluon | 2023-02-14 09:37