Animation will only play the first frame and then cut away

Godot Version

Godot 4

Question

Im trying to make so when the function pause_and_disappear is called, it will pause the game for 5 seconds then the “Disappear” animation will play but when i do it, it only plays the first fame then goes immediately to the idle animation

func pause_and_disappear():
	await get_tree().create_timer(5.00).timeout
	player_sprite.play("Disappear")

Heres the only code that would interfere with it at all

func _physics_process(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta
		
	if (velocity.x > 1 || velocity.x < -1):
		player_sprite.animation = "Running"
	else:
		player_sprite.animation = "Idle"
	if (velocity.y < 0):
		player_sprite.animation = "Jumping"
	if (velocity.y > 0):
		player_sprite.animation = "Falling"

Why “would”? That code will interfere with it! Take a look here for a way to “solve” this:

Where would i call the update_animations()?

They mean that you are correct and the _physics_process code is playing new animations every frame that interfere with the Disappear playing. You could wrap the other animations in an if block

func _physics_process(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta
	
	# will only play other animations if Disappear is not playing
	if player_sprite.animaion != "Disappear":
		if (velocity.x > 1 || velocity.x < -1):
			player_sprite.animation = "Running"
		else:
			player_sprite.animation = "Idle"
		if (velocity.y < 0):
			player_sprite.animation = "Jumping"
		if (velocity.y > 0):
			player_sprite.animation = "Falling"
1 Like