Steering a Shape along a pathway

Hello all,

I want to steer a shape along a pathway. Let’s say a spaceship that first goes along x axis and when at a certain point stops and rotates slowly around its axis and then starts in another direction.

Like a framework with list of timers and different commands for the time periods. Ah, I must have done something like this…

But has anyone an example for this?



Do you want the shape to be locked to the path like a rail, and slide along it, or do you want it to be following a series of waypoints over time like a boid where it can be begin off the path and move onto it?

If you look at previous forum examples like LerpVectorsExample and LerpVectorsSimplified you will find some basic path-following objects.

Those are for objects x,y without orientation. If you wanted them to also turn, store x,y,r in the PVector, and draw the object with orientation r. Then place two nodes on the same path point like this:

0, 0, 0
100, 0, 0
100, 0, PI * 3/2.0
100, 100, PI * 3/2.0

Now the agent moves from point 0 to 1
Then turns in place to orientation 2
Then moves to point 3.


I am thinking you are referring to easing? This is an example.

I am thinking along the lines of a ship in the sea, it takes time to make a turn after you gave the command. Is this the concept you want to explore?



If it’s about easing, here’s another online example: :grinning:


Thanks everyone for the great help!

I digged a bit into this and my experience is this:

My goal was to animate a ship for a movie. So no interactivity involved.

when you have a slow animation of a ship, that’s going forward 3.2 seconds and then brakes for 0.7 seconds and turns 90 degrees: Don’t rely on millis()!

Because when you add complex decorations, like a couple of clouds or birds flying by or other ships, the amount of millis since the end of setup() doesn’t stay the same. In fact, running on windows, the time can even vary when you don’t change the code (e.g. when you have hard drive access because of storing the movie/images).

Better than millis() would be to use a x-position (or x,y,z): when the ship has reached this point, start to brake until speed is 0. Then start to turn until angle is 90. millis() ain’t your friend.