class_name AnimationComponent extends Node var player: AnimationPlayer var state: StateComponent func _ready(): state = owner.find_child("State") state.transitioned.connect(on_transition) player = $AnimationPlayer func on_transition(_from: StateComponent.State, to: StateComponent.State): match to: StateComponent.State.Idle: player.play("human/idle") StateComponent.State.Run: player.play("human/run-fast") StateComponent.State.Jump: player.play("human/jump") StateComponent.State.Fall: player.play("human/fall") StateComponent.State.None: player.play("human/RESET") func play(action_name: StringName, speed: float = 1.0): player.speed_scale = speed player.play(action_name)