-
What was achieved?
I was able to make a curved road by creating Bézier Curves (cubic) and placing segments on the points through code. -
What is the issue? Include screenshots / videos if possible!
Whenever a curve is created, there are noticeable gaps between the segments. I want to fill in these gaps so the road looks smoother.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried changing the pivot point of the segment, but the curve still has gaps between them whenever the curve direction alternates.
Here’s the current pivot point of the segment model:
Here’s part of the code that places the segments:
local segments = 35
local curve = workspace.Folder
local model = workspace.RoadSegment
local a = p1.Position -- start
local b = c1.Position -- control point 1
local c = c2.Position -- control point 2
local d = p2.Position -- end
local lastPos
for t = 0,1,1/segments do
local bezierPos = cubicBezier(a,b,c,d,t)
if lastPos then
local posDist = (bezierPos - lastPos).Magnitude
local clone = model:Clone()
for _,v in pairs(clone:GetChildren()) do
if v:IsA("BasePart") then
-- Primary part has to be scaled from the Z axis
if v == clone.PrimaryPart then
v.Size = Vector3.new(v.Size.X,v.Size.Y,posDist)
else
v.Size = Vector3.new(posDist,v.Size.Y,v.Size.Z)
end
end
end
clone:PivotTo(CFrame.lookAt(bezierPos,lastPos))
clone.Parent = curve
end
lastPos = bezierPos
end
btw I want to fill in these gaps with code, not by plugin (GapFill).