Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[CFrame] How would I make this even more smooth movement?

Asked by 10 years ago

[!!] Im NOT asking for a request. (Obv) [!!]

Anyways.. This runs fast and fairly smooth, but the problem is, when I walk the the parts in a cirle around my head they lag and I dont like that, at all. I would like them to not skip some vector3'ing to get to there position. I had someone look at this a couple days ago and he just told me "#CamelRotation2015".

Can anyone help me making this not so laggy when talking or at least show me a few points of slowness?

local Rot1 = .1
local Rot2 = .001
local LerpRot = .03

function ConnectTablets()
    coroutine.wrap(function()
        for _, Player in pairs(game.Players:GetPlayers()) do
            local CurrentTabs = {}
            local Character_Pos = nil
                for Index,Tablet in next,Gravity_V4._Tablets do
                if(not(Tablet.Tab and Tablet.Tab:isDescendantOf(workspace)))then
                    ypcall(game.destroy,Tablet.Tab);
                    table.remove(Gravity_V4._Tablets,Index);
                elseif(Tablet.Plr==Player.userId)then
                    table.insert(CurrentTabs,Tablet);
                end;
            end;
        pcall(function()
        if Player.Character.Parent ~= nil and Player.Character.Torso.Parent ~= nil then
            Rot1=Rot1+Rot2
            pcall(function() 
                Character_Pos = CFrame.new(Player.Character:WaitForChild("Head").CFrame.p) 
            end)
            local run,error = ypcall(function()
                for i,v in pairs(CurrentTabs) do
                    if v.Tab.Parent ~= nil and v.Plr == Player.userId then
                        local Radius1 = CFrame.new(0,0,-4.5-#CurrentTabs)
                        local Radius2 = Radius1*CFrame.Angles(math.rad(25),0,0)
                        local cfr = Character_Pos*CFrame.Angles(.001,math.rad((i*(360/#CurrentTabs))+Rot1),0)*Radius2 -- 360/#Gravity_V4._Tablets
                        local Pos = v.Tab.CFrame.p
                        Pos = Pos:Lerp(cfr.p,LerpRot)
                        v.Tab.CFrame = CFrame.new(Pos)*v.Gyro.cframe
                        v.Gyro.cframe = v.Gyro.cframe*CFrame.Angles(math.rad(.1),math.rad(.1),math.rad(.1))
                    end
                end
            end)
            if not run then print(error) end
        end
        end)
        end
    end)()
end

Answer this question