Hello, I’m setting Humanoid.CameraOffset every render frame to keep it perfectly aligned with the character’s eyes (this adds animation bobbing to the camera and a few other fun things, but I’m getting off track). The problem I’m having is that the camera update seems to lag behind by a frame or two. This happens in both local and online environments.
Outdated/probably irrelevant information
Here is a dump of the script (also included in the repro file below) I’m using to change CameraOffset, in case this is a problem on my end:
wait()
local plr = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
_G.services = {
run = game:GetService("RunService")
}
repeat wait() until plr.Character
local char = plr.Character
local function UpdateLookVertical(target,theta)
local width = char.Humanoid.BodyWidthScale.Value
local height = char.Humanoid.BodyHeightScale.Value
local headScale = char.Humanoid.HeadScale.Value
local neckC0 = CFrame.new(0, (0.5*height) + (0.25*headScale), 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2*height, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
target.Head.Neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(theta*0.75, 0, 0);
target.UpperTorso.Waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(theta*0.25, 0, 0);
if target == char then
char.Humanoid.CameraOffset = char.HumanoidRootPart.CFrame:vectorToObjectSpace(char.Head.Position - char.HumanoidRootPart.Position)
+ char.HumanoidRootPart.CFrame:vectorToObjectSpace((char.Head.CFrame.UpVector*0.25*headScale) + (char.Head.CFrame.LookVector*0.4*headScale))
- Vector3.new(0, (1.5/height) + (0.5/headScale), 0)
end
end
_G.services.run:BindToRenderStep("UpdateViewModel",Enum.RenderPriority.Camera.Value - 1,function() UpdateLookVertical(char,math.asin(cam.CFrame.LookVector.Y)) end)
Here is a repro place file (MinimumRepro.rbxl) (100.6 KB) and the repro steps:
- Start a test server and zoom into first person. Look down and spin the camera around the Y-axis. Note the choppy movement.
- Disable game.StarterGui.ClientCore and start another test server. Zoom into first person and repeat, note the character stays perfectly aligned with the camera now that CameraOffset is no longer being changed.
After running the repro myself again and disabling the script that modifies CameraOffset after looking down (so CameraOffset is still set to a non-default value but isn’t being actively updated), the issue still persists; it seems that so long as the camera’s target point is off centre from the character’s head, the issue shown in the video below occurs:
If you still want to run the repro yourself, the file and instructions are in the details above.
Edit: Cleaned up code formatting. | 2: Fixed title. | 3: Added video. | 4: Updated bug report with new information and changed title.