2024-02-02 20:12:14 +01:00

57 lines
1.2 KiB
GDScript

extends Node
@export var animation_player: AnimationPlayer
@export var blend_time: float
var next_animation: StringName = "RESET"
func _ready():
assert(animation_player)
assert(blend_time >= 0.0)
func _process(_delta):
play("idle")
if animation_player.current_animation == next_animation:
return
animation_player.play(next_animation, blend_time)
func play(action_name: StringName):
next_animation = action_name
# func air(y_velocity: float):
# if y_velocity > 0:
# play("rifle_jump")
# else:
# play("falling")
# func aim(move: Vector2, is_shooting: bool):
# if move.x > 0:
# play("rifle_aim_strafe_right")
# elif move.x < 0:
# play("rifle_aim_strafe_left")
# elif move.y < 0:
# play("rifle_aim_walk_forward")
# elif move.y > 0:
# play("rifle_aim_walk_backward")
# else:
# play("rifle_aim")
# if is_shooting:
# play("rifle_shoot")
# func run(move: Vector2, is_shooting: bool):
# if move.y < 0:
# play("rifle_run_forward")
# elif move.y > 0:
# play("rifle_run_backward")
# elif move.x > 0:
# play("rifle_run_right")
# elif move.x < 0:
# play("rifle_run_left")
# elif is_shooting:
# play("rifle_shoot")
# else:
# play("rifle_idle")