How do I make so that the animation doesn't get interrupted by another in Animation Player Godot4?

Godot Version



So I am trying to make a three input game, where the player can press high, mid or low. My issue at the moment seems that when doing an input, everytime I press the next one it will skip the previous one and start playing the new animation. Is there a way to prevent that from happening?

extends CharacterBody2D

func _process(_delta):
	if Input.is_action_pressed("high_1"):
	if Input.is_action_pressed("mid_1"):
	if Input.is_action_pressed("low_1"):

Also I tried using the code below to make the animation return to the idle but I get an error regarding the _process()

	if $AnimatedSprite.playing():

You can AnimationPlayer.queue() the next animation to play as long as they don’t loop.

You get the error because you don’t have any node called AnimatedSprite as child of the root node of your scene.

How would I use AnimationPlayer.queue() exactly? Would I just insert it below every $ and specify the timing or do I have to do something else, also $AnimationPlayer doesn’t have a playing function, do I use is_playing instead?

Just call $AnimationPlayer.queue("my_animation") and it will queue and play that animation after the current animation is finished.

Yes. It’s better to read the documentation to know what each function does and test it by yourself that to wait for someone else to give you the green light.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.