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.
NOTE: BezierPath is NOT a traditional bezier spline. it behaves more like a linear spline that curves around each point.
NOTE: BezierPath has precomputation in it already. so no need to cache anything in your projects.
BezierPath can be installed using Wally:
BezierPath = "omrezkeypie/[email protected]"
A code snippet showing how to set up and use BezierPath.
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
A short video showing BezierPath.
2023-12-15.22-47-15.mp4
- BezierPath.new(Positions,CurveSize)
Takes in a table of positions which will be used as the waypoints for the spline and takes in a number to control the size of the curve between the waypoints and returns the path object.
- Path:CalculateUniformCFrame(T)
Takes in a T value from 0-1 and returns a uniform cframe across the path object.
- Path:CalculateUniformPosition(T)
Takes in a T value from 0-1 and returns a uniform position across the path object.
- Path:GetPathLength()
Returns the path objects length.