Here’s what I mean:
Behind the ControlPart = Rotates strangely
Here’s what I mean:
I mean StartPart not ControlPart sry*
I think it might just be a math problem. I’m testing it out in my studio and if all three parts (start, end, control) are lined up on any axis, when it turns the rotation on the control is too steep for it to look natural. If you move the control to the side it will look better.
red is end
green is start
blue is control
on here, all three parts are lined up and the turn is really steep
But if you move the blue off the alignment to the side, the rotation is smoother
Yes… is there any way to fix this?
try this: (just copy paste it into the studio command bar)
local StartPart = workspace.StartPart
local ControlPart = workspace.ControlPart
local EndPart = workspace.EndPart
local numPoints = 10
local tempFo = Instance.new("Folder")
tempFo.Parent = workspace
tempFo.Name = "THIS IS THE CURVE FOLDER"
--starting up direction
local up = Vector3.new(0, 1, 0)
for i = 1, numPoints do
local t = i / numPoints
local slerpPosition = StartPart.Position:Lerp(ControlPart.Position, t):Lerp(ControlPart.Position:Lerp(EndPart.Position, t), t)
local nextT = (i + 1) / numPoints
local nextPosition = StartPart.Position:Lerp(ControlPart.Position, nextT):Lerp(ControlPart.Position:Lerp(EndPart.Position, nextT), nextT)
local direction = (nextPosition - slerpPosition).Unit
--compute the new up direction
local right = up:Cross(direction).Unit
up = direction:Cross(right).Unit
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1, 1, 1)
newPart.Anchored = true
newPart.Position = slerpPosition
newPart.CFrame = CFrame.fromMatrix(slerpPosition, direction, up)
newPart.Parent = tempFo
---orientation marker
local marker = newPart:Clone()
marker.Size = Vector3.new(0.2, 1, 0.2)
marker.CFrame = newPart.CFrame * CFrame.new(0, 1, 0)
marker.Color = Color3.new(0, 1, 0)
marker.Material = Enum.Material.Neon
marker.Parent = newPart
end
Ok, yes, that generally works, but when I move the curve it gets weird
Can you send the code you’re using to move it? I’m not running into that issue
local StartPart = workspace.StartPart
local ControlPart = workspace.ControlPart
local EndPart = workspace.EndPart
local numPoints = 10
local tempFo = Instance.new("Folder")
tempFo.Parent = workspace
tempFo.Name = "THIS IS THE CURVE FOLDER"
local up = Vector3.new(0, 1, 0)
local function Update()
for i, Part in pairs(tempFo:GetChildren()) do
if Part.Name == "Part" then
Part:Destroy()
end
end
for i = 1, numPoints do
local t = i / numPoints
local slerpPosition = StartPart.Position:Lerp(ControlPart.Position, t):Lerp(ControlPart.Position:Lerp(EndPart.Position, t), t)
local nextT = (i + 1) / numPoints
local nextPosition = StartPart.Position:Lerp(ControlPart.Position, nextT):Lerp(ControlPart.Position:Lerp(EndPart.Position, nextT), nextT)
local direction = (nextPosition - slerpPosition).Unit
--compute the new up direction
local right = up:Cross(direction).Unit
up = direction:Cross(right).Unit
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1, 1, 1)
newPart.Anchored = true
newPart.Position = slerpPosition
newPart.CFrame = CFrame.fromMatrix(slerpPosition, direction, up)
newPart.Parent = tempFo
---orientation marker
local marker = newPart:Clone()
marker.Size = Vector3.new(0.2, 1, 0.2)
marker.CFrame = newPart.CFrame * CFrame.new(0, 1, 0)
marker.Color = Color3.new(0, 1, 0)
marker.Material = Enum.Material.Neon
marker.Parent = newPart
end
end
EndPart:GetPropertyChangedSignal("Position"):Connect(function()
Update()
end)
Update()
OMG you are the nicest person I know here, the fact that you sat down and tried to help me for free is really not a given. THANK YOU SO MUCH really!
There’s also a cubic bezier curve right beside the main blocks where you can move both parts to make a cooler curve
I could really use your help more often if I come across problems like this again. I don’t know anyone else who knows this area as well as you
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.