khanat-client/scenes/creatures/ra/ra_model.gd

44 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

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:
2021-01-21 21:03:44 +00:00
animation_tree.active = true
func set_move_direction(direction: Vector3) -> void:
2021-01-21 21:03:44 +00:00
move_direction = direction
animation_tree["parameters/walk/blend_position"] = direction.length()
func set_is_moving(value: bool) -> void:
2021-01-21 21:03:44 +00:00
is_moving = value
# animation_tree["parameters/conditions/is_moving"] = value
func transition_to(state_id: int) -> void:
2021-01-21 21:03:44 +00:00
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")