SlimeoosOdyssey/godot/Models/grape_man.gd

43 lines
1.1 KiB
GDScript

extends Node3D
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
@onready var player_sounds = $PlayerSounds
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", $GrabPointLocation.global_transform)
func animation_key_pickup_completed():
pickup_animation_in_progress = false
emit_signal("pickup_animation_finished")
func _on_animation_tree_animation_finished(anim_name):
if anim_name == "WalkHold":
player_sounds.set_stream(preload("res://sfx/dropgrunt.ogg"))
player_sounds.play()