Path (A Performant Module for Creating Paths)

This is @kjerandp’s Curve Interpolator implemented into Roblox and fully-typed in Luau.

A module meant for creating paths from a group of points and then being able to interact with the path to get what you want (examples demonstrated in the Demo).

Roblox Files and Code: GitHub - surfbryce/Path: Takes @kjerandp's Curve Interpolator and ports it to Roblox (with better Terminology, Documentation, and Optimizations)
Roblox Model: https://create.roblox.com/marketplace/asset/15493350845/Path

What you are seeing in this Demo are a few things you can do with this Module:

  • Rendering a Path from any number of points
  • Getting the Point AND Curvature on a Path at any Progress point
    • Black dot traveling along the Path with its Pink (Tangent)/Blue (Normal) directional lines
  • Locating the Closest Point on the Path to a Provided Position
    • Bright Yellow dot and Light Yellow dot
  • Getting all the Points that INTERSECT an Axis at the Provided Value
  • Paths with different Curviness/Softness values
    • All with Curviness = 1 and Softness: Red = 0, Green = 0.5, Blue = 1)

You can download this demo from the GitHub and run (using the Server-View) exactly what is in the video.

This is a fully-typed and documented Roblox Luau implementation.
So if you ever need to see how something works, understand a concept, check the types, or find out what certain options do, it’ll all be in the code and explained.

This implementation is also extremely optimized compared to the original, being able to call the GetPointAtTime method 100,000 TIMES in only 18ms with an equal amount of unique "time"s being used. It is also the fastest implementation available on the Roblox platform with an API this extensive.

If you are interested in seeing if anything else could be optimized/improved please go ahead and take a look at the codebase, and if you do find anything, make a PR! Once a PR is made I will update everything accordingly.

57 Likes

Very cool, looks really good. Thank you for open sourcing this as well as hosting a repo on github!

Amazing, Thank you so Much!
Nice scripts!

FYI: Made an update that improves the accuracy of the Intersection method - specifically with values too small to have originally fit within the Epsilon filter method. Doesn’t affect anything just removes edge-cases.

1 Like

this is really nice, i was having performance issues using other path modules

This is a cool module, I agree that more performant is better, but I have a question: Is this module only looping or ends when it reaches some point?

Depends on what you mean here?

The Path module primarily works by you providing a time/progress scale value and that returns a value on the path.

So in my demo file, I wrap the progress value from [0, 1].

So there’s nothing automated. You can check the code/demo file to learn more!

1 Like