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

How do I make this CFrame movement less choppy?

Asked by 4 years ago
Edited by User#24403 4 years ago

I'm creating a tool for a game that has parts orbiting around the player. Currently, I'm listening for the RunService.Heartbeat event in a module that moves three parts around a player. On the server, the parts move smoothly, but on the client, the parts move in a choppy manner. I'm aware that this is because the server can only send updates to the client at 20Hz, but I don't know how to approach switching this movement over to RenderStepped while still having the same look to other players. What should I do?

On the client: https://gyazo.com/472ec68efb53c460f7c6e2d0417a325e

On the server: https://gyazo.com/472ec68efb53c460f7c6e2d0417a325e

Here is my code:

local Jutsu = {}
    Jutsu.spawn = function(Player, Name, Antiex)
    local i = 0
    local speed = 0.1
    local speed2 = .03
    local speed3 = .06
    local incline = math.rad(45)
    local incline2 = math.rad(-45)
    local incline3 = math.rad(0) 
    local distance = 5

    local Scorch = script.Scorch
    local ball = Scorch:Clone()
    ball.Parent = workspace
    local ball2 = Scorch:Clone()
    ball2.Parent = workspace
    local ball3 = Scorch:Clone()
    ball3.Parent = workspace
    local planet = Player.Character.Torso


    spawn(function()
        wait(30)
        movement:Disconnect()
        ball:Destroy()
        ball2:Destroy()
        ball3:Destroy()
    end)

    movement = game:GetService("RunService").Heartbeat:Connect(function()
            i = i + 1
            ball.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline, i * speed3, 0) * CFrame.new(0, 0, distance)
            ball2.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline2, i * -speed, 0) * CFrame.new(0, 0, distance)
            ball3.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline3, i * speed2, 0) * CFrame.new(0, 0, distance)
    end)

    end 
return Jutsu

Extra note: When I finish fixing the movement, I plan to add damage to all of the parts.

1
The game experience should be smooth. Just handle this all on the client side. Period. Movement like this should be processed on the player playing the game, not the server. User#24403 69 — 4y
0
Do not do any sort of part animations on the server. All animations should be client side. AIasdair 50 — 4y
0
You can tween CFrames Fad99 286 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Instead use SetPrimaryPartCFrame:lerp(finishPos, acceleration) or use BodyPosition or BodyVelocity.

Ad

Answer this question