meat_madness_redux/godot/tests/elevator/ElevatorTracker.gd

29 lines
709 B
GDScript3
Raw Normal View History

2022-11-27 13:31:09 -07:00
extends Spatial
var at_top: bool = true
export var track_animation_name = ""
export var vertex_animation_name = ""
signal arrived
func _ready():
var _err = $AnimationPlayer.connect("animation_finished", self, "_on_AnimationPlayer_animation_finished")
func toggle():
if at_top:
descend()
else:
ascend()
at_top = not at_top
func descend():
$AnimationPlayer.play(track_animation_name)
$"../ElevatorVertexAnimation/AnimationPlayer".play(vertex_animation_name)
func ascend():
$AnimationPlayer.play_backwards(track_animation_name)
$"../ElevatorVertexAnimation/AnimationPlayer".play_backwards(vertex_animation_name)
func _on_AnimationPlayer_animation_finished(_anim_name):
emit_signal("arrived")