# How do you find the CFrame of the camera if you were to revert the CameraOffset

I am making an FPS system and I have a camera bobbing system using Humanoid.CameraOffset. I am trying to find what position the camera would be at if there was no CameraOffset. This would make it appear that your camera is moving but the gun’s ViewModel is stationary.

How do I find the position that my camera would be at if there was no CameraOffset without actually setting the CameraOffset to (0,0,0)?

Camera bobbing equation:

``````if Humanoid.MoveDirection.Magnitude > 0 then
local bobbleX = math.cos(tick() * 10) * .25
local bobbleY = math.abs(math.sin(tick() * 10)) * .25

local bobble = Vector3.new(bobbleX, bobbleY, 0)

Humanoid.CameraOffset = Humanoid.CameraOffset:lerp(bobble, .25)
else
Humanoid.CameraOffset = Humanoid.CameraOffset * .75
end
``````

Store the offset as a variable or as an attribute and load that variable in when doing calculations:

``````local v3 = -- Camera:GetAttribute("Offset") or Vector3.new(OffsetX, OffsetY, OffsetZ)
--[[
Set "v3" to the cameras offset
every time you change it
--]]

local originalCamPos = camera.Position - v3 -- Getting the camera position based off of offset
``````

You can subtract the camera offset from the camera’s position or CFrame. You can get the humanoid with Camera.CameraSubject.

Example (CFrame):

``````local camera --set to camera
local newCFrame = camera.CFrame - camera.CameraSubject.CameraOffset
``````

Example (Position):

``````local camera --set to camera
local newPosition = camera.CFrame.Position - camera.CameraSubject.CameraOffset
``````

That wouldn’t work because when you rotate your character, the offset stays as relative to world instead of relative to the humanoidrootpart

1 Like

I found a solution and it was a lot simpler than I thought it would be

``````local x,y,z = Camera.CFrame:ToEulerAnglesXYZ()
CFrame.new(Character.HumanoidRootPart.Position+Vector3.new(0,1.5,0))*CFrame.Angles(x,y,z)
``````