Triggering non looping animations

Godot Version



I’m currently trying to make a player animation system where whenever you aren’t moving it plays a looping idle animation, and whenever you start moving in a direction it triggers a one shot animation corresponding to whichever direction you are going. however currently, it either plays the idle animation until you start moving then plays only the first frame of each corresponding movement animations untill you stop moving which lets the direction animation play, OR it only plays the first frame of each corrisponding movement animation. i have been following this tutorial:
and this is my code:

extends CharacterBody2D
#controll player speed in the editor
@export var move_speed : float
#find animation tree
@onready var animation_tree = $AnimationTree
@onready var state_machine = animation_tree.get("parameters/playback")
#movement code
func _ready():
func  _physics_process(_delta): #physics
	#get input direction
	var input_direction = Vector2(
		Input.get_action_strength("right") - Input.get_action_strength("left"),
		Input.get_action_strength("down") - Input.get_action_strength("up"),
	#update velocity to new direction
	velocity = input_direction.normalized()* move_speed
	#makes player move

#syncs animation with movement
func update_animation_parameters(move_input : Vector2):
	if(move_input != Vector2.ZERO):
		animation_tree.set("parameters/Move/blend_position", move_input)
#when not moving make animation idle 
func pick_new_state(move_input : Vector2):
	if(velocity != Vector2.ZERO):"Move")
1 Like

IDK what im talking about but;
The first thing I caught is


The docs say that this is for use with joysticks or else you’ll get a 0 or 1 return. Maybe thats the problem if you are using a keyboard?

Also use ``` before and after code snippets to make it looks pretty.

1 Like

ok thx