43 lines
1.0 KiB
GDScript
43 lines
1.0 KiB
GDScript
@tool
|
|
extends Node2D
|
|
|
|
|
|
@export var pos1 : Vector2 = Vector2(0,0)
|
|
@export var pos2 : Vector2 = Vector2(2,9)
|
|
@export var debugging : bool = false
|
|
# Called when the node enters the scene tree for the first time.
|
|
@export var speed : int = 1
|
|
|
|
var cur = 0
|
|
|
|
func _ready():
|
|
if not Engine.is_editor_hint():
|
|
$start.global_position = pos1
|
|
$end.global_position = pos2
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
if Engine.is_editor_hint():
|
|
$start.global_position = pos1
|
|
$end.global_position = pos2
|
|
if not debugging:
|
|
return
|
|
|
|
var tweener = get_tree().create_tween()
|
|
if cur == 0:
|
|
tweener.tween_property($Platform,"global_position",pos1,speed)
|
|
await tweener.finished
|
|
$Platform.queue_redraw()
|
|
$Platform.global_position = pos1
|
|
await get_tree().create_timer(3).timeout
|
|
cur = 1
|
|
elif cur == 1:
|
|
tweener.tween_property($Platform,"global_position",pos2,speed)
|
|
await tweener.finished
|
|
$Platform.queue_redraw()
|
|
$Platform.global_position = pos2
|
|
await get_tree().create_timer(3).timeout
|
|
cur = 0
|
|
|