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:
![]()