40 lines
1.1 KiB
GDScript
40 lines
1.1 KiB
GDScript
extends Spatial
|
|
|
|
var at_top: bool = true
|
|
export var track_animation_name = ""
|
|
export var vertex_animation_name = ""
|
|
export var vertex_animation_path: NodePath
|
|
export var playback_speed: float
|
|
|
|
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():
|
|
$"../Slurp".play()
|
|
yield(get_tree().create_timer(0.1), "timeout")
|
|
$AnimationPlayer.play(track_animation_name)
|
|
get_node(vertex_animation_path).play(vertex_animation_name)
|
|
$AnimationPlayer.playback_speed = playback_speed
|
|
get_node(vertex_animation_path).playback_speed = playback_speed
|
|
|
|
|
|
|
|
func ascend():
|
|
yield(get_tree().create_timer(0.1), "timeout")
|
|
$AnimationPlayer.play_backwards(track_animation_name)
|
|
get_node(vertex_animation_path).play_backwards(vertex_animation_name)
|
|
$AnimationPlayer.playback_speed = playback_speed
|
|
get_node(vertex_animation_path).playback_speed = playback_speed
|
|
|
|
func _on_AnimationPlayer_animation_finished(_anim_name):
|
|
emit_signal("arrived")
|