64 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-02-02 19:12:14 +00:00
extends Node
2024-02-02 23:57:33 +00:00
@export var character: Character
2024-02-02 19:12:14 +00:00
@export var animation_player: AnimationPlayer
var next_animation: StringName = "RESET"
func _ready():
2024-02-02 23:57:33 +00:00
assert(character)
2024-02-02 19:12:14 +00:00
assert(animation_player)
func _process(_delta):
2024-02-02 23:57:33 +00:00
if character.velocity.y > 0:
2024-02-03 11:23:56 +00:00
play("human/jump")
elif character.velocity.y < 0:
play("human/falling")
2024-02-02 23:57:33 +00:00
elif character.direction != Vector3.ZERO:
2024-02-03 11:23:56 +00:00
play("human/run")
2024-02-02 23:57:33 +00:00
else:
2024-02-03 11:23:56 +00:00
play("human/idle")
2024-02-02 19:12:14 +00:00
if animation_player.current_animation == next_animation:
return
2024-02-03 11:23:56 +00:00
animation_player.play(next_animation)
2024-02-02 19:12:14 +00:00
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")