29 lines
709 B
GDScript
29 lines
709 B
GDScript
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")
|