# Is there another option similar to Bezier Curves?

I know how to use Bezier Curves but the only issue is that the control points only slightly influence the curve, but I want the curve to hit the center of all the points. I’ve searched for it but never find a solution.

1 Like

You might be looking for something similar to Hermite Cubic spline curves. This algorithm hits all points plotted except the first and last points.

1 Like

Yeah, that’s exactly what I’m looking for. I’ve found a module that accepts only one number and not a Vector3, do you know how I would go about changing this?

What do you mean by

That makes no sense

You can only add points as integers and not Vector3 types since the module wasn’t made for luau and instead vanilla lua

Can you screenshot or copy/paste the module’s code so I can look.

``````local spline_meta = {
addPt = function( self, x )
table.insert( self.x, x );
if self.n > 1 then
self.dxdt[self.n] = 0.5 * (x - self.x[self.n-1]);
end
table.insert( self.dxdt, 0 );
self.n = self.n + 1;
end;
evaluate = function( self, t )
if t < 0 then
t = 0;
elseif t >= self.n-1 then
if self.n <= 1 then
assert( self.n > 0 );
return self.x[1];
end
t = self.n - 1.0001;
end
local it, ft = math.modf( t );
local x0, dx0 = self.x[it+1], self.dxdt[it+1];
local x1, dx1 = self.x[it+2], self.dxdt[it+2];
local pi = (3 - 2 * ft) * ft * ft;
return x0*(1-pi) + x1*pi + dx0*ft*((ft-2)*ft+1) + dx1*ft*ft*(ft-1);
end;
pop = function( self )
if self.n > 0 then
table.remove( self.x );
table.remove( self.dxdt );
self.n = self.n - 1;
if self.n > 0 then
self.dxdt[self.n] = 0;
end
end
end;
};
spline_meta.__index = spline_meta;

function NewSpline()
local t = {
n = 0;
x = { };
dxdt = { };
};
setmetatable( t, spline_meta );
return t;
end
``````

Okay this is a object type module. You can find what I mean here: All about Object Oriented Programming

With this module you need to set the curve to a variable then add points like so:

``````local curve = Module.NewSpline();
curve.addPt(Vector3)``````

That’s not what I was saying, you can see on line 4 that it’s meant for integers only. I know how to use the module but just not with Vector3s

The argument `t` seems to refer to where on the curve you want to get a position: 0 refers to the start of the curve, 1 or more is the end or somewhere before it etc.
Therefore, a Vector3 would make no sense here.

Looking solely at the signatures of all the functions, though, this code doesn’t make sense. You give it one number, and get back one number, not an x,y or x,y,z position.

Try finding something that gives you an actual position.