class_name AnimationComponent extends CharacterComponent @export var skip_frames: int = 0 var animations: AnimationPlayer var state: StateComponent var accumulated_delta: float var skipped_frames: int func _ready(): state = character.get_node("State") state.transitioned.connect(on_transition) animations = %AnimationPlayer func _process(delta): accumulated_delta += delta if skipped_frames >= skip_frames: animations.advance(accumulated_delta) accumulated_delta = 0 skipped_frames = 0 else: skipped_frames += 1 func on_transition(_from: StateComponent.State, to: StateComponent.State): match to: StateComponent.State.Idle: animations.play("human/idle") StateComponent.State.Run: animations.play("human/run-fast") StateComponent.State.Jump: animations.play("human/jump") StateComponent.State.Fall: animations.play("human/fall") StateComponent.State.None: animations.play("human/RESET") func play(action_name: StringName, speed: float = 1.0): animations.speed_scale = speed animations.play(action_name)