Move Sprite in a path array taken from code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dfoxworks
:warning: Old Version Published before Godot 3 was released.

Hi,

I have this path array:
path = [Vector2(128, 0), Vector2(128, -192), Vector2(320, -192), Vector2(320, 64), Vector2(448, 64)]

Its a road type path, consisting of right degree angles. But i want to be able to move the using code for different sprites i can instance. So first sprite instance might have only 3 path points, the second one could have 7 path points. Hope that makes sense.

:bust_in_silhouette: Reply From: mollusca

You could add the points to a Curve2D and then use one of Curve2D’s interpolate methods to get a position along the path.