Create Move Points in Curve for 2 Points

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Muricy

Thanks to anyone who can help…
In this situation my yellow amoeba is moving through a matrix of points to point A … arriving at point A, it needs to go to point B …
But this movement needs to be done in an arc … as in the blue line.
I tried CURVE2D, but it returned a straight line …
Can someone help me create this matrix of points between 2 vectors in the form of a curve.
Thanks!

:bust_in_silhouette: Reply From: njamster

Take a look at quadratic Bezier curves:

const COMPLETION_TIME = 5.0
var time_passed = 0.0

var A = Vector2(100, 100)
var B = Vector2(300, 300)

var X = Vector2(B.x, A.y)

func _physics_process(delta):    
	if time_passed < COMPLETION_TIME:
		time_passed += delta
		var f = time_passed / COMPLETION_TIME
		var Y = A.linear_interpolate(X, f)
		var Z = X.linear_interpolate(B, f)
		position = Y.linear_interpolate(Z, f)

Thanks!!! Work fine!

Muricy | 2020-02-05 22:12