Improved animations

This commit is contained in:
2024-02-03 12:23:56 +01:00
parent b815a6603c
commit 3fb5ede6fa
2 changed files with 9 additions and 19 deletions

View File

@ -2,27 +2,27 @@ extends Node
@export var character: Character
@export var animation_player: AnimationPlayer
@export var blend_time: float
var next_animation: StringName = "RESET"
func _ready():
assert(character)
assert(animation_player)
assert(blend_time >= 0.0)
func _process(_delta):
if character.velocity.y > 0:
play("female/jump")
play("human/jump")
elif character.velocity.y < 0:
play("human/falling")
elif character.direction != Vector3.ZERO:
play("female/run")
play("human/run")
else:
play("female/idle")
play("human/idle")
if animation_player.current_animation == next_animation:
return
animation_player.play(next_animation, blend_time)
animation_player.play(next_animation)
func play(action_name: StringName):
next_animation = action_name