Hello, I’m working on a camera system like bodycam and I have come across an issue.
The camera is buttery smooth but upon moving left or right with A and D the camera tilts like in the video.
game:GetService("RunService").RenderStepped:connect(function()
checkfirstperson()
if isfirstperson == true then
visiblearms(true)
local delta = uis:GetMouseDelta()
rightshoulderclone.Transform = rightshoulder.Transform
leftshoulderclone.Transform = leftshoulder.Transform
local finalcf = (camera.CFrame*walksway*jumpsway*strafesway*CFrame.Angles(math.rad(sway.Y*swaysize),math.rad(sway.X*swaysize)/10,math.rad(sway.Z*swaysize)/2))+(camera.CFrame.UpVector*(-1.7-(headoffset.Y+(aimoffset.Value.Y))))+(camera.CFrame.LookVector*(headoffset.Z+(aimoffset.Value.Z)))+(camera.CFrame.RightVector*(-headoffset.X-(aimoffset.Value.X)+(-(sway.X*swaysize)/75)))
viewmodel:SetPrimaryPartCFrame(CFrame.new(finalcf.Position, Vector3.new(mouse.Hit.Position.X, mouse.Hit.Position.Y, mouse.Hit.Position.Z)))
if character:FindFirstChildWhichIsA("Tool") then
if camera.CameraType == Enum.CameraType.Custom then
enableviewmodel()
end
camera.CameraType = Enum.CameraType.Scriptable
else
if camera.CameraType == Enum.CameraType.Scriptable then
disableviewmodel()
end
camera.CameraType = Enum.CameraType.Custom
end
if camera.CameraType == Enum.CameraType.Scriptable then
rootpart.CFrame = rootpart.CFrame:Lerp(CFrame.new(rootpart.Position, Vector3.new(pos.X+5,0,pos.Z)),0.5)
local divisor = 0.1
camera.CFrame = camera.CFrame:Lerp(CFrame.new(character.Camera_Part.Position, Vector3.new(pos.X+5,0,pos.Z)),divisor)
end
end
end)
That is the script, I have narrowed it down to this part of it
if camera.CameraType == Enum.CameraType.Scriptable then
rootpart.CFrame = rootpart.CFrame:Lerp(CFrame.new(rootpart.Position, Vector3.new(pos.X+5,0,pos.Z)),0.5)
local divisor = 0.1
camera.CFrame = camera.CFrame:Lerp(CFrame.new(character.Camera_Part.Position, Vector3.new(pos.X+5,0,pos.Z)),divisor)
end
If I up the divisor, the A and D mouse tilt is completely gone. No tilt whatsoever. But the mouse becomes uncontrollable, as it moves too fast and the camera spins super quickly. If I lower the divisor again, the camera/mouse becomes manageable and smooth, but the A and D tilt comes back.