Using animation as ability cooldown (can't specify _animation_finished signal?)

Godot Version

Godot_v4.7.2

Question

Hi, I’m new to coding and Godot. I’m trying to teach myself and it’s a struggle.

I want to create a cooldown for my “pet” ability using an animation in the animation player. I’ve tried a lot of different things and everything’s come up with another issue. (I’m sure there’s something fundamental I’m not understanding but I can’t figure it out and I’ve searched everywhere.)

I just want to tell the game to count the pet, play the “bounce” animation, play the cooldown animation and disable petting while it’s playing, and then enable petting again when the cooldown animation finishes. Any help is much appreciated.

extends Area2D

@onready var pet_total: Label = $"../GameManager/PetTotal"
@onready var george_anim: AnimationPlayer = $GeorgeSprite/AnimationPlayer

# Petting variables.
var pets : int = 0
var pet_ready : bool = true

# When the player hitbox exits George, a pet is counted.
func _on_body_exited(_body: Node2D) -> void:
	if pet_ready == true:
		pets += 1
		pet_total.text = str(pets)
		pet_ready = false
		george_anim.queue("bounce")
		george_anim.queue("cooldown")
		return

# im stand defeated at the doorstep to my first adversary \(o_o)/
func _on_animation_player_animation_finished(_cooldown: StringName) -> void:
	if george_anim.is_finished("cooldown") == true:
		pet_ready = true
	else:
		pass

(Yes, the signal is connected.) The error I’m getting with my current code is this:

image

is_finished() is not a valid method of AnimationPlayer. If animation_finished signal is properly connected to your _on_animation_player_animation_finished() function, then simply check the value of that StringName argument you receive. If that is equal to “cooldown” then your last queued animation is finished.

I’m not sure how to go about doing that or what to write. I’m just trying to specify that the _on_animation_player_animation_finished()only applies to the “cooldown” animation and not any others.

func _on_animation_player_animation_finished(animation_name: StringName) -> void:
	if animation_name == "cooldown":
		pet_ready = true

Thank you so much!! I didn’t know local variables were a thing. :sweat_smile: