Character/camera stuttering when rotating

I have this issue where the camera or character stutters whenever the player looks around. The weird thing is that it only happens when the camera is set to LockFirstPerson and not classic. Even weirder still is that its the same camera script i used in another game and it works fine over there, but not here (even though i have not edited the script in any way). Any way i can fix this?


here’s the code used:

local function MouseInputLoop()
	y += mouse.Value.X/50
	x += mouse.Value.Y/50

	x = math.clamp(x, math.rad(-80), math.rad(80))
	aimRemote:FireServer(x)
end

local function CameraLoop(dt)		
	inputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	--Updates rootPart per frame to point with camera

	local cf = CFrame.new(hrp.CFrame.Position)
	hrp.CFrame = cf * CFrame.Angles(0, -y, 0)
	
	--Makes torso move up and down based on camera
	char.UpperTorso.Waist.C0 = CFrame.new(char.UpperTorso.Waist.C0.Position) * CFrame.Angles(-x, 0, 0)
	
	--moves camera to camera part
	camPart.Eyes.C0 = CFrame.new(head.CFrame:ToObjectSpace(hrp.CFrame):Inverse().Position) * char:GetAttribute("CameraOffset")
	cam.CFrame = camPart.CFrame * CFrame.Angles(-x, 0, 0)
	
	char.Head.LocalTransparencyModifier = 1
end

runService:BindToRenderStep("CameraLoop", Enum.RenderPriority.Character.Value, CameraLoop)
runService:BindToRenderStep("MouseLoop", Enum.RenderPriority.Camera.Value, MouseInputLoop)

I have already tried moving the function priorities with no results, and i cant keep the camera to Classic since it messes up the character’s movement.

its because dt is not constant, so you have to adjust your movement based on dt

for my camera system i think i had a constant value for expected framerate (1/60) and then divided dt by that value and then multiplied the movement by that

edit: if youre using a remote event to tell the server to move the arm then its going to have a delay from lag

Well your just setting the cframe value your not even smoothing it using lerp LOL

cam.CFrame = cam.CFrame:Lerp(camPart.CFrame * CFrame.Angles(-x,0,0))

There should be no need to smooth it out if its updating every camera frame.

1 Like

you need to add interpolation to get the maximum smoothness, it doesnt matter if its firing every frame lil bro

when you set values precisely it leads to abrupt changes, abrupt changes = not smooth

the result will be jittery because your instantly jumping to the next value

Found the issue, it was just that my code and Roblox’s AutoRotate function was overriding each other causing the stuttering. I ended up disabling AutoRotate and its smooth now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.