Improved animations
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user