extends Node

onready var slide_friction = 2
onready var tween_values = []

export var x_target = 0
export var y_target = 0
export var speed = 32

var time

# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	var start = Vector2(0,0)
	var end = Vector2(x_target, y_target)
	tween_values.append(start)
	tween_values.append(end)
	time = start.distance_to(end)/speed
	_start_tween()
	
func _start_tween():
	$FlyTween.interpolate_property($PlatformBody, "position",
	tween_values[0], tween_values[1], time,
		Tween.TRANS_SINE, Tween.EASE_IN_OUT)
	$FlyTween.start()
	

func _on_FlyTween_tween_completed(object: Object, key: NodePath) -> void:
	tween_values.invert()
	_start_tween()
