Improved animations
This commit is contained in:
64
client/player/AnimationController.gd
Normal file
64
client/player/AnimationController.gd
Normal file
@ -0,0 +1,64 @@
|
||||
class_name AnimationController
|
||||
extends Node
|
||||
|
||||
@export var character: Character
|
||||
@export var animation_player: AnimationPlayer
|
||||
|
||||
var next_animation: StringName = "RESET"
|
||||
|
||||
func _ready():
|
||||
assert(character)
|
||||
assert(animation_player)
|
||||
|
||||
func _process(_delta):
|
||||
if character.velocity.y > 0:
|
||||
play("human/jump")
|
||||
elif character.velocity.y < 0:
|
||||
play("human/falling")
|
||||
elif character.direction != Vector3.ZERO:
|
||||
play("human/run")
|
||||
else:
|
||||
play("human/idle")
|
||||
|
||||
if animation_player.current_animation == next_animation:
|
||||
return
|
||||
|
||||
animation_player.play(next_animation)
|
||||
|
||||
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")
|
Reference in New Issue
Block a user