mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-12-23 18:08:46 +00:00
43 lines
1.2 KiB
GDScript
43 lines
1.2 KiB
GDScript
extends Spatial
|
|
class_name Mannequiny
|
|
# Controls the animation tree's transitions for this animated character.
|
|
|
|
# # It has a signal connected to the player state machine, and uses the resulting
|
|
# state names to translate them into the states for the animation tree.
|
|
|
|
|
|
enum States {IDLE, RUN, AIR, LAND}
|
|
|
|
onready var animation_tree: AnimationTree = $animation_tree
|
|
onready var _playback: AnimationNodeStateMachinePlayback = animation_tree["parameters/playback"]
|
|
|
|
var move_direction: = Vector3.ZERO setget set_move_direction
|
|
var is_moving: = false setget set_is_moving
|
|
|
|
|
|
func _ready() -> void:
|
|
animation_tree.active = true
|
|
|
|
|
|
func set_move_direction(direction: Vector3) -> void:
|
|
move_direction = direction
|
|
animation_tree["parameters/walk/blend_position"] = direction.length()
|
|
|
|
|
|
func set_is_moving(value: bool) -> void:
|
|
is_moving = value
|
|
# animation_tree["parameters/conditions/is_moving"] = value
|
|
|
|
|
|
func transition_to(state_id: int) -> void:
|
|
match state_id:
|
|
States.IDLE:
|
|
_playback.travel("idle")
|
|
States.LAND:
|
|
_playback.travel("land")
|
|
States.RUN:
|
|
_playback.travel("walk")
|
|
States.AIR:
|
|
_playback.travel("jump")
|
|
_:
|
|
_playback.travel("idle")
|