How to move a square from point A to point B along a line?

Godot Version

4.3

Question

I want to make a square (starting at point A) move along a straight line to point B. I’ve attached an image to show what I mean. The movement should:

Follow the line between A and B.
Be smooth, with control over the speed.

Could someone guide me on how to achieve this? A code example or steps would be greatly appreciated!

Path2D and PathFollow2D are great for this. You can make your Path2D of two points, add a PathFollow2D as a child and increase it’s progress over time.

1 Like

Thank you so much! This worked perfectly, and my square is now moving smoothly from point A to point B. I really appreciate your help and the clear explanation. It made everything much easier to understand!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.