SlimeoosOdyssey/godot/Models/grape_man.gd

43 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

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 15:41:47 -06:00
@onready var player_sounds = $PlayerSounds
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():
emit_signal("anim_check_grab", $GrabPointLocation.global_transform)
2023-08-19 14:49:36 -06:00
func animation_key_pickup_completed():
pickup_animation_in_progress = false
emit_signal("pickup_animation_finished")
2023-08-19 15:41:47 -06:00
func _on_animation_tree_animation_finished(anim_name):
if anim_name == "WalkHold":
player_sounds.set_stream(preload("res://sfx/dropgrunt.ogg"))
player_sounds.play()