# Lerp/Bezier Module?

Hello developers and scripters specifically, I’m looking for:

A module which generates a curve using 2 intermediate points as influence between 2 endpoints. I need to be able to plug in T (time) and get back a Vector3 or CFrame.

I’ve tried using the Bezier Curve roblox wiki to make my own, but I get lost about halfway through every time. I have my own clunky script from 2014 which kinda does what I’m after, but it’s jittery. I’m looking to have a camera and set of models follow individual paths that I set. The reason I need a path/curve to be generated between the points I set is because without that, the camera’s angle changes by upwards of 10 degrees every time a new point is reached, which is very noticeable and annoying in the final recording.

Can anyone help out?

4 Likes

^This one is pretty good just import the plugin and look at the module

2 Likes

There is also this stand alone module by @Crazyman32.

2 Likes

Yeah my module is optimized for both cubic and quadratic cases, but it can also solve bezier curves of any degree (i.e. you could have 100 control points).

3 Likes

2 Likes

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
2 Likes

can you give an example of a quadratic lerp with ur module, I cant figure out how to use it

I need help with your module, I followed your example and got it working but I want the curve to keep updating base on the players position, so I made a working model with a loop that calls your module.

local A, B, C = someVector3Positions…
local NewPart = Instance.new(“Part”)
while t < 0.99 do
game:GetService(“RunService”).Heartbeat:Wait()
C = char.HumanoidRootPart.Position
curve = Bezier.new(A, B, C)

… the other codes …
end

The NewPart followed my player and completed the curve but it looks rather choppy… I think I’m suppose to pass an updated table into your module during the loop but I’m not sure how.