Character Jittering When Changing Rotation

I’ve been implementing a sort of custom movement system for my game and while changing the position of the character works perfectly, I’ve been having issues with rotating it along with the camera. I’m aiming for a smooth rotation like how the default Shift Lock works, but whatever I’ve tried makes it look desynchronized and jittery.
rotation

(ignore the framerate, studio’s recorder is pretty meh)
Here’s the relevant code:

local cam = workspace.CurrentCamera
local char = script.Parent
local run_s = game:GetService("RunService")

function update_camera(dt)
	local cam_ray = cam:ViewportPointToRay(cam.ViewportSize.X / 2, cam.ViewportSize.Y / 2)
	local v = cam_ray.Origin + cam_ray.Direction * 1000
	char:PivotTo(CFrame.new(char:GetPivot().Position, v))
end

run_s:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value + 1, update_camera)

I should mention two things:

  1. The model’s pivot doesn’t need to replicate to the server since I’m planning for this to be a singleplayer only game and it doesn’t fit my use case.
  2. Another part of the code changes the model’s position with MoveTo before the update_camera function changes the pivot. I tried to set the rotation within the function that uses MoveTo (changing it to PivotTo) but that didn’t fix the issue. I don’t know if combining them would work as part of a solution since that function has a lower RenderPriority value than Camera, but it’s worth a try.

I’ve also tried changing the RenderPriority value and the jitter still remained. Any help is appreciated and thanks in advance.

Try anchoring the HumanodRootPart of your character.

All of the parts are anchored already.

Turns out the solution was set it at the beginning of update_camera and multiply the direction by a larger number (I just did 9,999,999).

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