0 votes

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.

enter image description here

in Engine by (14 points)

1 Answer

0 votes

Take a look at quadratic Bezier curves:

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)
by (10,483 points)

Thanks!!!! Work fine!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.