Hello guys,
I’ve been trying to fix this problem for weeks but I can’t find an answer anywhere. How can I ensure that the Bezier curve always only stays on one side or the rotation of the parts. As soon as the end part goes behind the start part, the curve turns from the point where it is over 180 degrees. But I want the curve to stay on the side:
local StartPart = workspace.StartPart
local ControlPart = workspace.ControlPart
local EndPart = workspace.EndPart
local numPoints = 10
for i = 1, numPoints do
local t = i / numPoints
local slerpPos = CFrame.new(
StartPart.Position:Lerp(ControlPart.Position, t):Lerp(ControlPart.Position:Lerp(EndPart.Position, t), t)
)
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1, 1, 1)
newPart.Anchored = true
newPart.Position = slerpPos.Position
local nextT = (i + 1) / numPoints
local nextPos = CFrame.new(
StartPart.Position:Lerp(ControlPart.Position, nextT):Lerp(ControlPart.Position:Lerp(EndPart.Position, nextT), nextT)
)
local direction = (nextPos.Position - newPart.Position).Unit
newPart.CFrame = CFrame.lookAt(newPart.Position, newPart.Position + direction)
newPart.Parent = workspace
end
when you say stay on one side, do you mean in relation to the worldspace so it’s not curved on the X/Z axis or the actual local space of the brick to be a consistent orientation?
Yes, exactly, I want to make a roller coaster construction system and would like to include loops, but it always turns to the other side at a certain point