Curvy path movement using waypoints and Catmull-Rom splines

  • 5 favourites

Attached Files

The following files have been attached to this tutorial:

.capx

catmull-rom-spline-waypoints.capx

Download now 189 KB

Stats

1,243 visits, 1,784 views

Translations

This tutorial hasn't been translated.

Tools

A method for implementing non-linear paths using Catmull-Rom splines.

Disclaimer: the math used in this capx was put together by R0J0hound, who posted it here in his own capx way back in the day. All I did was take what he made and added a few features to it.

Whereas the original capx by R0J0 made use of the IID of the Waypoints, this one uses variable IDs like in other Waypoint systems found in other tutorials around the site.

If you want constant-ish movement, you can try rex's MoveTo behavior and replace the "Set position" with "Move to XY." Each waypoint should be about equal distance from the waypoints before and after it, the Sprite's MoveTo.MaxSpeed should be set less than or equal to that distance, and its rate set to 1. It seems the more waypoints there are in a path, the more 'constant-ish' the movement will be, so play with that to get the result you want.

Benefits:

- The ability to set up multiple individual paths around your layout

- Paths can be taken forwards or backwards just by changing the polarity of the Sprite's 'rate' variable

- Simple, straightforward ID and grouping system

- No arrays needed (I just hate these for some reason)

Edit:

R0J0hound updated his own capx to also make use of multiple paths. You can find it here.

Benefits of R0J0's:

- All of the above benefits

- Can even use decimal numbers to set the order of the waypoints, thus giving you the ability to insert waypoints into the path without needing to change the indices of the others (Ex: If you have waypoints with indices 1 and 2, you can set one in between them by giving it the index 1.3 or 1.5)

- No need to set the number of waypoints in a path like in mine

- It's much prettier

Hope you find it useful!

.CAPX

catmull-rom-spline-waypoints.capx

Download now 189 KB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!