Hello! First of all i need to point out that i’m using :PivotTo()
to clone from ServerStorage
the new “chunks”.
I’ve been searching and i found out that moving models with :PivotTo()
is a bit laggier than only moving using CFrame
, but it’s the only way that i could achieve this infinite path made as i was moving with the train.
As you can see on this video, moving the train itself does not affect on the user FPS, but, as i was generating new parts, my FPS was going down and down, probably because of the velocity i was generating it.
And now i am in doubt, it is because of the way that i am moving parts? It is because of the velocity that i am generating it?
In case of curiosity, i am using ModelStreamingBehavior
on workspace
already, and I made a simply but effective optimizer deleting the parts as it generated a certain quantity.
The main base of the script is this:
ProceduralGen.Event:Connect(function(hitbox)
for i, End in pairs(workspace.Procedural:GetDescendants()) do
if End.Name == "End" then
EndPart = End
end
end
local possibleparts = game.ServerStorage.Parts:GetChildren()
local randompart = possibleparts[PartsR.random:NextInteger(1, #possibleparts)]
local NextPart = randompart:Clone()
NextPart.Parent = workspace.Procedural
NextPart.PrimaryPart = NextPart.Start
NextPart:PivotTo(EndPart.CFrame)
local Sequence = Instance.new("NumberValue")
Sequence.Parent = NextPart
Sequence.Name = "Sequence"
Sequence.Value = 0
hitbox:Destroy()
EndPart:Destroy()
end)
There’s some chance it could be the way I designed it? or simply the speed i was generating it?
I was thinking too that it might be solved by making the generated parts longer, but i don’t know if it’ll be effective in long time, as it might have lag spikes when generating one per time.
Feel free to ask any question if needed!