How do I check when a specific animation in animation player is finished?

Newest Version

So I have a top down game. Im trying to add a roll mechanic where the player can press a button, it will then boost the player in the direction they are facing. The problem is I want to resume normal movement once the roll animation is finished, but it wont detect when its finsihed


extends CharacterBody2D

const speed = 75
var accel = 5000
var friction = 900
var is_rolling = false
var roll_speed = 300
var roll_direction = Vector2.ZERO  # Variable to store roll direction

var input = Vector2.ZERO

func _physics_process(delta):
	if Input.is_action_just_pressed("roll") and not is_rolling:
		roll_direction = get_roll_direction()
		is_rolling = true
		velocity = roll_speed * roll_direction  # Set initial velocity

	elif is_rolling:
		velocity = roll_speed * roll_direction  # Update velocity each frame during roll animation

		if velocity.x != 0 or velocity.y != 0:
		if Input.is_action_pressed("left"):
			$Sprite2D.flip_h = true
		if Input.is_action_pressed("right"):
			$Sprite2D.flip_h = false
		input = get_input()
		if input == Vector2.ZERO:
			if velocity.length() > (friction * delta):
				velocity -= velocity.normalized() * (friction * delta)
				velocity = Vector2.ZERO
			velocity += (input * accel * delta)
			velocity = velocity.limit_length(speed)

func _on_animation_finished(anim_name: String, anim_finished: bool):
	if anim_name == "Roll":
		is_rolling = false

func get_input():
	input.x = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left"))
	input.y = int(Input.is_action_pressed("down")) - int(Input.is_action_pressed("up"))
	return input.normalized()

func get_roll_direction():
	if Input.is_action_pressed("down"):
		return Vector2.DOWN
	if Input.is_action_pressed("up"):
		return Vector2.UP
	if Input.is_action_pressed("left"):
		return Vector2.LEFT
	if Input.is_action_pressed("right"):
		return Vector2.RIGHT
		if $Sprite2D.flip_h == true:
			return Vector2.LEFT
			return Vector2.RIGHT

if _on_animation_finished is connected to the animation_finished signal then this should work, though it only emits a string so the second argument must be an additional bind. Do you get any errors? What would a print(anim_name) say?

So sorry, I was on vacation with family sorry for the late reply, I got it working, I ended up just using a timer the length of the animation