SlimeoosOdyssey/godot/Models/grape_man.gd

41 lines
1.1 KiB
GDScript

extends Node3D
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
@onready var pickup_bone_idx = $rig/Skeleton3D.find_bone("PickupBone")
signal anim_check_grab(position: Vector3)
var pickup_animation_in_progress = false
signal pickup_animation_finished
func idle_empty():
animation.travel("IdleEmpty")
func walk_empty():
animation.travel("WalkEmpty")
func walk_hold():
if pickup_animation_in_progress:
await pickup_animation_finished
animation.travel("WalkHold")
func pickup():
pickup_animation_in_progress = true
animation.travel("Pickup")
func idle_hold():
if pickup_animation_in_progress:
await pickup_animation_finished
animation.travel("IdleHold")
func animation_key_grab():
emit_signal("anim_check_grab", get_pickup_bone_location())
func get_pickup_bone_location() -> Vector3:
var trans = $rig/Skeleton3D.global_transform * $rig/Skeleton3D.get_bone_global_pose(pickup_bone_idx)
return trans.origin
func animation_key_pickup_completed():
pickup_animation_in_progress = false
emit_signal("pickup_animation_finished")