Play Animation Completely?

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

Im not sure why but every time i tell Godot to play a Animation it only plays it when the button is held down instead of Press and Play the Animation from Start to Finish im still new to animations.

Can some one help me with what is going on, its pretty basic how the code works its like this:

if Input.is_action_pressed("X_Button"):
		anim_to_play = "Jump"

Thank you


is_action_pressed only returns true if you are currently pressing the button.

You want to use is_action_just_pressed, although I’m not sure if that would fix your issue because I don’t know how you are handling your animation.

Can you share the part of your code that plays the animation?

(the code snippets are also hyperlinks to the docs)

Zoford | 2021-06-02 19:56

Its pretty basic its mostly from AnimationPlayer

the code is this that i use:

var current_anim = anim_player.get_current_animation()
if current_anim != anim_to_play:

I did try the is_action_just_pressed but that one hardly plays the animation so im still not sure what to do

HaptikRevamp | 2021-06-02 21:01

I ended up fixing the issue it turns out it needed “func _Input(event)” but now the issue is the animation wont stop playing and it now constantly loops. Any idea on how to stop the animation?

HaptikRevamp | 2021-06-03 22:41

Make sure your animation isn’t set to loop. (top right corner of the animation tab)
Also read this if you haven’t already. This part talks a bit about looping animations.

Zoford | 2021-06-04 21:02

None of the animations are using any form of looping what so ever if anything there is no actual sign of any looping going on it just loops.

Also something as simple as say Jump and play a jump animation does not even work properly at times the animation wont stop and in others it will not even play at all i had seen some tutorials but many of them dont really work on my end for some reason so im mostly spending hours trying to figure this out.

HaptikRevamp | 2021-06-04 21:26