I think maybe the problem is you are using CFrames rather than using the physics system., if you used a hinge with a motor i have the feeling it would all run alot more smoothly. Its not actually lagging i think its just that the minimal possible cframe alteration is far too large. So ditch the Cframes weld it all together and try using the inbuilt physics…?
I’ll try it, thank you
anyway guess i’ll open another thread about this one twitching bug to see if some experts can solve or give tips about
What actually was the twitching bug? I thought that what we were talking about? I’m guessing the twitching isnt a bug, that just what CFrames look like up close. They only usually look nice because they are usually a thousandth of the size… I guess the other thing to try is to tween between the Cframes or just Tween the entire rotation…
[Edit: forgot to publish its working now]
I been experimenting, the physics system is def the way to go… Use an hinge
Have a look inside the big blue rotating boxes in my test area, it even works with complex lighting setups.
P.s…Also ignore the other stuff they are discarded assets from a game that is no longer in production, they may be repurposed later…
CFrame:Lerp()
Is basically a CFrame function that can move and rotate parts really smoothly.
local part = Instance.new("Part", workspace) Part.Anchored = true for i = 0, 1, 0.0001 do part.CFrame = part.CFrame:Lerp(part.CFrame * CFrame.Angles(0,0,math.rad(45)), i) wait(0.01) end
So you just hinged the whole model and used weld or used the hinge with the model in other way?
I’ll try it asap
Ok i’ve tried this with
local part = script.Parent.PrimaryPart
local RS = game:GetService("RunService")
local model = script.Parent
RS.Heartbeat:Connect(function()
-- The code you already had to rotate it
for i = 0, 1, 0.0001 do
part.CFrame = part.CFrame:Lerp(part.CFrame * CFrame.Angles(0,0,math.rad(4.5)), i)
wait(0.01)
end
end)
and the only thing rotating is the Primary part, guess i have to weld everything
That’s perfect, but RS.Heartbeat won’t be needed.
local part = script.Parent.PrimaryPart
local RS = game:GetService("RunService")
local model = script.Parent
-- The code you already had to rotate it
for i = 0, 1, 0.0001 do
part.CFrame = part.CFrame:Lerp(part.CFrame * CFrame.Angles(0,0,math.rad(4.5)), i)
wait(0.01)
end
-- removed the RS heartbeat
so you mean this with all parts welded?
Ok so, actually this is the really best solution, everything is welded and on “Anchored” off and rotates good without lag (actually tried only on all walls without internal objects)
I have only one question:
The rotation seems incremental and after a bit it goes too much fast, is there a way to set a max speed or slow down when reaches too much speed?
Not sure, but try setting
for i = 0, 1, 0.0001 do
to
for i = 0, 1, 0.01 do
it seems to change only the time it takes to stop.
I’ll try something to make the speed constantly or slow down
Alright, make sure to mark the solution!
yeah no problem, thank you man.
Ok so i’ve resolved the issue it follows an equation easy as complicated
basically:
for i = 0, 1, 0.001 do
part.CFrame = part.CFrame:Lerp(part.CFrame * CFrame.Angles(0,0,math.rad(3)), i)
wait(0.01)
So this will be
Until i will be <= 1 add 0.001 to i every 0.01 seconds then stop.
at this point the speed according to CFrame will increase until his max that will be the value of i
So will be (i x speed(CFrame [3] )) untill i will reach 1
So speed will be 3 at max
To stop this increase you can do
(0,0,math.rad(3)), 1)
Changing from i to 1 it will be just " speed = CFrame [3] until i will reach 1"
Putting them together in two different loops will make the model spin gradually and then spin at the same velocity until i will reach 1
Hope to have given a good explanation and sorry for bad english and grammar mistakes.