Lerp/Bezier Module?

Using my Bezier module, you can do what you desire with the following code example:

local A, B, C, D = someVector3Positions...

local Bezier = require(myBezierModule)

-- Create the curve solver (no calculations done yet):
local curve = Bezier.new(A, B, C, D)

-- Solving for time 't' with a defined speed:
local t = ???
local speed = 5

local distance = speed * t
local length = curve:GetLength(0.01) -- High-res length approximation
local point = curve:Get(distance / length) -- 'Get' is a lerp function for the path

-- 'point' is a Vector3 world position

Note that the ‘Get’ method has an optional ‘clamp’ boolean parameter, which will keep the point from going out of bounds of the path. This is useful when you need to connect multiple paths together.

20 Likes