For some reason animations arnt working

Godot Version

`Godot 4.4

Question

`For some reason the animation isnt working here is the Code :
extends CharacterBody3D

@export var walk_speed: float = 5.0
@export var sprint_speed: float = 8.0
@export var acceleration: float = 10.0
@export var deceleration: float = 15.0
@export var jump_velocity: float = 4.5
@export var mouse_sensitivity: float = 0.005
@export var camera_pitch_limit: float = 75.0
@export var roll_speed: float = 12.0
@export var roll_duration: float = 0.6

var gravity: float = 9.8
var velocity_change: Vector3 = Vector3.ZERO

@onready var camera: Camera3D = $CameraHead/SpringArm3D/Camera3D
@onready var pivot: Node3D = $CameraHead
@onready var animation_tree: AnimationTree = $AnimationTree

var yaw: float = 0
var pitch: float = 0
var is_sprinting: bool = false
var is_rolling: bool = false
var roll_timer: float = 0.0
var roll_direction: Vector3 = Vector3.ZERO

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
animation_tree.active = true

func _input(event):
if event is InputEventMouseMotion:
yaw -= event.relative.x * mouse_sensitivity
pitch -= event.relative.y * mouse_sensitivity
pitch = clamp(pitch, -deg_to_rad(camera_pitch_limit), deg_to_rad(camera_pitch_limit))
pivot.rotation.x = pitch
rotation.y = yaw

func _process(delta):
if is_rolling:
handle_roll(delta)
return

var input_vector = Vector3.ZERO
if Input.is_action_pressed("move_forward"):
	input_vector -= transform.basis.z
if Input.is_action_pressed("move_backward"):
	input_vector += transform.basis.z
if Input.is_action_pressed("move_left"):
	input_vector -= transform.basis.x
if Input.is_action_pressed("move_right"):
	input_vector += transform.basis.x

input_vector = input_vector.normalized()

is_sprinting = Input.is_action_pressed("sprint")
var target_speed = sprint_speed if is_sprinting else walk_speed

if input_vector.length() > 0:
	velocity_change = velocity_change.lerp(input_vector * target_speed, acceleration * delta)
	if is_sprinting:
		animation_tree.set("parameters/StateMachine/current", "Run")
	else:
		animation_tree.set("parameters/StateMachine/current", "Walk")
else:
	velocity_change = velocity_change.lerp(Vector3.ZERO, deceleration * delta)
	animation_tree.set("parameters/StateMachine/current", "Idle")

if not is_on_floor():
	velocity.y -= gravity * delta
	animation_tree.set("parameters/StateMachine/current", "Jump")

if Input.is_action_just_pressed("jump") and is_on_floor():
	velocity.y = jump_velocity
	animation_tree.set("parameters/StateMachine/current", "Jump")

if Input.is_action_just_pressed("roll") and is_on_floor():
	start_roll(input_vector)

velocity.x = velocity_change.x
velocity.z = velocity_change.z

move_and_slide()

func start_roll(direction: Vector3):
if direction.length() == 0:
return

is_rolling = true
roll_timer = roll_duration
roll_direction = direction.normalized() * roll_speed
animation_tree.set("parameters/StateMachine/current", "Roll")

func handle_roll(delta):
roll_timer -= delta
if roll_timer <= 0:
is_rolling = false
return

velocity = roll_direction
move_and_slide()

Hi, usually for a state machine, you need get the AnimationNodeStateMachinePlayback and call functions on it. What does your state machine in the AnimationTree look like?