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

Make camera movement smooth?

Asked by
Aimarekin 345 Moderation Voter
6 years ago

Hey there! I've been messing up with camera manipulation because I wanted to make a script that makes the camera follow a part, and everything is working fine. But there is something I don't like. It's not really a glitch or anything, It's actually that the camera isn't completely "smooth". When the part moves, the camera moves, and I can notice like a "trail" of the ball's movement. It is a bit "ugly" to see the ball like a laggy car. When I use cars in ROBLOX, I don't notice any trails. Is there anyway to make a camera move more "Smoothly"?

local cam = nil
local ball = nil

script.Parent.MouseButton1Click:connect (function ()
    game.ReplicatedStorage.PlayerPlaysHole1:FireServer(game.Players.LocalPlayer)
    local ball = game.Workspace.MinigolfBalls:WaitForChild("Ball".. game.Players.LocalPlayer.UserId)
    local cam = game.Workspace.CurrentCamera
    cam.CameraType = Enum.CameraType.Scriptable
    cam.CameraSubject = ball
    while true do
        wait ()
        cam.CoordinateFrame=CFrame.new(ball.CFrame.X, ball.CFrame.Y + 5, ball.CFrame.Z + 10)
    end
end)

For if you ask, the client has network ownership.

0
try making the ball transparent or making it smaller EpicAshtonTheBoy 33 — 6y
0
Nah It's yet small and it can not be transparent. Aimarekin 345 — 6y
0
You could use game:GetService('TweenService'):Tween() or use CameraObject:Interpolate. Bisoph 5 — 6y

1 answer

Log in to vote
1
Answered by
cabbler 1942 Moderation Voter
6 years ago

Camera renders 60fps but wait() is 30fps, so it is not synced; 'laggy'.

You want: BindToRenderStep

--threw in some efficiency
local RS = game:GetService("RunService")
local zoom = Vector3.new(0,5,10)

RS:BindToRenderStep("asdf",Enum.RenderPriority.First.Value,function()
    cam.CFrame = CFrame.new(ball.CFrame.p+zoom)
end)
0
Thanks! I didn't knew about BindToRenderStep Aimarekin 345 — 6y
0
And also, thanks to that you answered my question I can backup from those 2 rep points I lost for downvoting two dummies... Aimarekin 345 — 6y
Ad

Answer this question