hello all, hope everyone is well
I wanted to create a scene in godot 4.4 where my character increases a counter whenever a animation is finished. 2 animations are a idle(coolness) and attack as a test animation and they loop which is neccessary. Each animation has it's own label and would increase when the button for it was pressed to play and the animation completed.
I have attempted this doing it in script but could not find something to signal it. I also tried with an animation player calling the animation complete functions on their animations but did not work.
the script:
#this scene handles a animation
#animation can be changed via button
extends Node2D
@onready var onyx: SpineSprite = $Onyx
@onready var coolness_idle = $VBoxContainer/CoolnessIdle
var coolness_count := 0
@onready var attack_amount = $VBoxContainer/AttackAmount
func ready():
#onyx.get_animation_state()..connect(on_animation_complete)
onyx.get_animation_state().set_animation("idle animation", true, 0)
func _on_idle_pressed():
onyx.get_animation_state().set_animation("idle animation", true, 0)
func _on_attack_pressed():
onyx.get_animation_state().set_animation("attack animation", true, 0)
func _on_Idle_animation_complete():
coolness_count += 1
coolness_idle.text = str("Amount of coolness = ", coolness_count)
print("idled")
func _on_Attack_animation_complete():
attack_amount += 1
attack_amount.text = str("Amount of attack = ", attack_amount)
print("attacked")
Guidance will be appreciated. I am completely stuck. Thank you