2023-08-19 01:31:24 -06:00
|
|
|
extends Node3D
|
|
|
|
|
2023-08-19 14:49:36 -06:00
|
|
|
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
2023-08-19 16:32:19 -06:00
|
|
|
@onready var pickup_bone_idx = $rig/Skeleton3D.find_bone("PickupBone")
|
2023-08-19 14:49:36 -06:00
|
|
|
|
2023-08-19 01:31:24 -06:00
|
|
|
signal anim_check_grab(position: Vector3)
|
|
|
|
|
|
|
|
var pickup_animation_in_progress = false
|
|
|
|
signal pickup_animation_finished
|
|
|
|
|
2023-08-19 14:49:36 -06:00
|
|
|
func idle_empty():
|
|
|
|
animation.travel("IdleEmpty")
|
|
|
|
|
|
|
|
func walk_empty():
|
|
|
|
animation.travel("WalkEmpty")
|
2023-08-19 01:31:24 -06:00
|
|
|
|
2023-08-19 14:49:36 -06:00
|
|
|
func walk_hold():
|
2023-08-19 01:31:24 -06:00
|
|
|
if pickup_animation_in_progress:
|
|
|
|
await pickup_animation_finished
|
2023-08-19 14:49:36 -06:00
|
|
|
animation.travel("WalkHold")
|
2023-08-19 01:31:24 -06:00
|
|
|
|
|
|
|
func pickup():
|
|
|
|
pickup_animation_in_progress = true
|
2023-08-19 14:49:36 -06:00
|
|
|
animation.travel("Pickup")
|
2023-08-19 01:31:24 -06:00
|
|
|
|
2023-08-19 14:49:36 -06:00
|
|
|
func idle_hold():
|
|
|
|
if pickup_animation_in_progress:
|
|
|
|
await pickup_animation_finished
|
|
|
|
animation.travel("IdleHold")
|
2023-08-19 01:31:24 -06:00
|
|
|
|
|
|
|
func animation_key_grab():
|
2023-08-19 16:32:19 -06:00
|
|
|
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
|
|
|
|
|
2023-08-19 14:49:36 -06:00
|
|
|
func animation_key_pickup_completed():
|
|
|
|
pickup_animation_in_progress = false
|
|
|
|
emit_signal("pickup_animation_finished")
|