I have a massive model; it consists of thousands parts. I constantly need to pivot-rotate it and it takes a few seconds to turn.
local rotation = CFrame.Angles(0, math.rad(0.01), 0)
while true do
local modelCFrame = P:GetPivot()
P:PivotTo(modelCFrame * rotation)
wait(30)
nd
As you can see, I simply put wait(30) to achieve the task, but it is not what I want. I need to call P:PivotTo only after the model has fully turned and loaded… and is seen well on the screen.
I tried this:
task.wait(P:PivotTo(modelCFrame * rotation))
and it still does not work the way I want.
Are there any other wait-methods?
ContentProvider can be a good service for doing that. If your model has meshes, decals, etc. simply put in ContentProvider:PreloadAsync() with the proper provided assets before the loop and it should work.
-- rest of the code
local ContentProvider = game:GetService("ContentProvider")
local assets = {
-- insert your assets in here
}
ContentProvider:PreloadAsync(assets)
while true do
local modelCFrame = P:GetPivot()
P:PivotTo(modelCFrame * rotation)
end
I’m not sure if it can work with regular parts, but you can always find other suitable ways.
I don’t believe you’re using task.wait() correctly. task.wait() is a drop-in replacement for wait recommended by Roblox.
It should also be noted that operations like this should use RunService.Heartbeat:Connect(). The physics engine only updates 30 times a second, so there’s little point updating it more than 30 times a second.
Not sure what you mean by this, :PivotTo() should be synchronously updating the positions of all the parts within the model, meaning that nothing else should be happening whilst :PivotTo() is still running.
Could you provide a video demonstrating the issue you’re having?
Unless adaptive timestepping is enabled the physics actually update at 240 hz (240 times a second) or 4 times in a frame, a frame happens 60 times a second by default.
Heartbeat runs 60 times a second, after the 4 physics timesteps have completed.
The model has no meshes, no decals… simply a few thousands of parts… Most of them have CanCollide, CanTouch and CastShadow as false, to improve fps. It really did! At the moment I think of splitting the whole model into a few models (a few tens, actually) and show only the visible side… I wonder why the engine does not do it.