Hello!
I’m pretty much done with this first person camera but I have noticed one issue with it.
When the player is moving backwards the camera gets offset either left or right and starts to jitter!
(look at the video below for an example)
As you can see when the player is moving backwards the camera slightly shifts left or right and begins to jitter.
(The issue seems to be related to the offset, I have no idea how to fix this)
Here is the code that sets the CameraPosition,
-- During the example video, PositionPart is set to the HumanoidRootPart
local CameraPosition = PositionPart.CFrame * CAMERA_OFFSET
local finalCameraRotation = CFrame.fromOrientation(rotationX, rotationY, math.rad(spring_Tilt.p))
local CameraRotation = previousCFrame:Lerp(finalCameraRotation, cameraRigidness.Value)
previousCFrame = CameraRotation
local finalCFrame = CFrame.new(CameraPosition) * CameraRotation
Camera.CFrame = finalCFrame
And here is the code that makes the player turn towards where the camera is looking.
local rX, rY, rZ = Camera.CFrame:ToOrientation()
local finalCFrame = CFrame.new(RootPart.CFrame.Position) * CFrame.Angles(0, rY, 0)
RootPart.CFrame = RootPart.CFrame:Lerp(finalCFrame,0.85)
Since you’re binding it to the heads CFrame this will happen. When moving backward (or sideways in the air) you jitter slightly which is what you’re seeing.
I’m almost certain if you lerp, or tween the position it won’t show the jittering (I could be wrong)
I have noticed that the jitter and left or right offset when going backwards is related to the offset I apply to CameraPosition (CAMERA_OFFSET). If I remove it, the jitter will disappear but the camera is then in the middle of the PositionPart which isn’t how it’s supposed to look.
Adding a lerp to the CameraPosition won’t really fix the left/right offset but will fix the jittering.
Also in the video PositionPart was HumanoidRootPart.
I’m having the exact same issue, except the highlighted solution here (which as far as I’m aware is equivalent to MouseBehavior.LockCenter) presents new issues for my custom camera that I only know how to solve by avoiding LockCenter and CameraRelative. Is there any other way besides removing the offset and faking it with a custom first person character?