BezierPath, an easy to use and optimized spline path module for TD games and general paths

Intro

BezierPath is an easy to use bezier spline module, designed to be used for TD games and general paths while being optimizied for large scale uses.

Code example

local BezierPath = "Path to the module"
local Positions = {
    Vector3.new(0,10,0),
    Vector3.new(10,0,0),
    Vector3.new(10,10,10)
}
local NewPath = BezierPath.new(Positions,3)
local Part = Instance.new("Part",workspace)
Part.Size = Vector3.new(1,1,1)
Part.Anchored = true

for t = 0,1,1/100 do
    Part.CFrame = NewPath:CalculateUniformCFrame(t)
    task.wait(0.1)
end

Optimization

Here is BezierPath against the old module i used for my TD game calculating uniform positions


(function1 is BezierPath)

Link to benchmarker i used: Benchmarker module
Link to old module i used: GitHub - ecurtiss/CatRom: Creates Catmull-Rom splines for Roblox.

Image and video examples


Github repo link

  • API documentation is in the github about me
82 Likes

whoa this awesome!!! its not like i had the repo before this released!!! bravo omrez

6 Likes

give me repo NOW! or else the catrom will be on your bed tonight

6 Likes

Another day, another victory for the gnomelandians. Taking down the blind copiers, the impaasotrs among us.

8 Likes

hippity hoppity your code is now my property

11 Likes

Omrez is too pro for us gnomelanders guys, now time to see everyone with this new module

4 Likes

This is truly a revolutionary release, thank you for the time and effort you put into this.

5 Likes

nuh uh i wont give you the repo loser

7 Likes

now i can torture myself by makin cutscene with this,…,.,.,.,

3 Likes

this module probably wouldn’t be the best option, id recommend catrom for cutscenes as its alot more smooth. unless you want to use this module’s behavior for cutscenes

3 Likes

nah there’s already a cutscene module with bezier path, just need it for lerpin models like helicopter

1 Like

I’ve been meaning to make something like this for a long time now and now this saves me the trouble! Sweet.

1 Like

Can you add a function that given a distance d it finds the position of it along the curve as example

arcLenght = 5

d=2.5

the point would be on the middle. This would help me on a project I am doing.

1 Like

I’m pretty sure this is already possible, the T in uniform CFrame/Position methods is an alpha value. If you give it the value of 0.5 it will be in the middle of the path.

1 Like

You can easily translate a distance value to a T value. In the module i made a function called :GetPathLength()
it returns the splines total length. With this you can easily get the needed T value by just doing
local T = Distance / PathLength

3 Likes

Someone else answered, but what you did there is getting the distance based on a tvalue, not the other way around

2 Likes

omrez, i am truly thankful for this amazing module bestowed unto me by the powers of total, peak roblox programming, in which leaves me bewildered as its beyond my puny understanding

4 Likes

Question, I might be dumb or so or I just can’t happen to be able to set it up right but for some reason it error that “new” is not a valid member of the module… Should not happen since .new() is literally a function in the module.

1 Like

are you requiring the module correctly? i see 0 reason for it to say .new does not exist apart from that reason

1 Like

Oh god im so stupid… I always forget to actually “require” it sorry for the time I wasted you. Thx for the help tho

1 Like