TopDown - Make Player follow an adaptive path


Hi everyone,

I have to make my player object follow a path (in blue on the picture).
This path is made of waypoints.
The player must always be on this path. It means that the path follow the player by shrinking along direction vectors.
These directions are obtained this way : greenDot_Position - waypoint_Start_Position, for each point.
Then i normalize these directions and use a Vector2.Lerp to move the points

My problem is : how to make the player always on the path?
I tried many approaches but none managed to act as expected.

Could anyone try the challenge and help me with this?

PS: the behavior of this is to mimic a magnetic signal received by the player, following a curve path.
The final destination is the last point of the curve( the down left one)

Hope this is clear.

Thanks by advance

I don’t understand what you are missing. You say you are Lerping between the points. Vector2.MoveTowards would probably be easier, but either can work.

If you put the player on such a lerped (or moved-toward) point, then, the player is always on the path.

Let me turn it around: how is the player not always on the path now?

The problem is when the player is between points. It is important to note that the player is moved and rotated freely. It is not locked on the part

So your player moves and rotates freely? Or it’s locked on the path?
I don’t quite get your problem. If it moves freely, then you can’t expect it to be always on the path. If it’s locked, then it can’t go off the path.
I think you need to explain more about your game.

Thanks for your concern. But i chose another solution/concept for my gameplay. The problem was indeed trying to keep the player on a track while moving freely.

Is there a way to mark this thread as solved?