Waypoints

Post your own tutorials, guides and demos.

Post » Fri Mar 27, 2009 2:36 am

A simple example of how to do paths.

The little scribbly thing goes through every waypoint, ordered by their index.
It has a private variable that tells it where to start (gets modified in runtime)
Waypoints have a private variable that tells its order (index).

You can have more than one instance of the sprite following the path at different points, just set the appropiate starting point in 'current'.

I was aiming for cubic interpolation, then I realized what I really needed was splines. That'd be useful. Maybe I'll try it some other day.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sat Mar 28, 2009 1:45 pm

Thanks! 8)
B
4
S
2
G
4
Posts: 401
Reputation: 2,302

Post » Wed Apr 01, 2009 9:39 pm

Smooth waypoints!

had to put in the formula for cubic, as the built-in cubic doesn't go through the control points.
Used the formula verbatim from http://local.wasp.uwa.edu.au/~pbourke/m ... rpolation/

It was suggested that a Hermite (http://www.cubic.org/docs/hermite.htm) would be a better fit.
As of now, speed is constant in each segment, which means there's a jump to the new speed on a segment jump.

Usage: set waypoint objects, set their PV index and time to reach from the previous waypoint. They're traversed incrementally 1 by one. Set the follower's sprite to the first point to be reached, there have to be at least 2 previous points from that one for the curve to do it's thing.

Toggle the make invisible action at the beginning of the sheet if you don't want to see the waypoints.

With help from Mipey.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Apr 01, 2009 10:54 pm

And here is my version, using cubic interpolation. The red dots are tangents (vectors from the waypoints based on angles).

I have yet to figure out how to make it move with constant speed!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest