I'm trying to make animated transitions, I've prepared the assets but I don't know how to do the code, maybe someone knows a simple way that can be applied to the code I wrote below


func _physics_process(delta):
	
	if Input.is_action_pressed("ingame_left"):
		velocity.x = -movementspeed
		$AnimatedSprite.play("run")
		
		##how to do idle to run animation transition?##
		
	elif Input.is_action_pressed("ingame_right"):
		velocity.x = movementspeed
		$AnimatedSprite.play("run")
		
	else:
		$AnimatedSprite.play("idle")
		
	if not is_on_floor():
		$AnimatedSprite.play("jump")

Also, video for context

I had figured out something similar with 2d, but I was using a state machine, the transition - in my case the character turning round - from one state to another was a separate state itself....

I used the yield to hold off doing anything until the animation had finished, THEN proeed to the new state.

if Input.is_action_pressed("left"):
	$AnimatedSprite.play("Turn")
	yield($AnimatedSprite, "animation_finished")
	_state_machine.transition_to("Move/Walk")

You might be able to just use the yield part to wait while your animation plays to do this.

If animation playing is idle and button pressed do the transition animation and wait for it to finish then do the next animation.

a year later