Apologies if the math for this isn’t as advanced as the title implies, I have been thinking about this problem for a week and feel no closer to the solution than I was previously. Any insight or assistance is appreciated.
To start, here is a basic rundown of my situation: I am programming a custom first person camera, this camera has multiple functions, but the primary one (the function I’m getting stumped by) is the ability for it to function at an angle. By “an angle”, I mean if the character were to fall on their back, or if an animation were to play, the camera would face the according direction instead of always facing forward with a roll value of 0.
I’ve programmed the basic camera system, 360 degree yaw rotation, pitch with limits, the issue is that I’m not sure how to add the CFrame of the torso to the offset of the camera. I’ve made some progress on the issue, I know that part of the problem is resulting from multiple of the same value being added together; for example; You add together the X axis of where your camera system thinks it is, but then you also add the x axis rotation of the torso, meaning that there is some duplication of the values.
With all that said, here are relevant portions of my code:
local function Mouse_Moved (delta:Vector2)
local effectiveDelta = Vector2.new(Config.camera.xSens * UserSettings.MouseSensitivity * -delta.X, Config.camera.ySens * UserSettings.MouseSensitivity * -delta.Y)
local newPitch --[[X]] = math.clamp(viewportVector.Y + effectiveDelta.Y, Config.viewport.minPitch, Config.viewport.maxPitch)
local newYaw --[[Y]] = (viewportVector.X + effectiveDelta.X)
viewportVector = Vector2.new(newYaw, newPitch)
local yawDiff = (torsoYaw - newYaw)
if math.abs(yawDiff) > Config.head.maxYaw then
torsoYaw = torsoYaw + ( (newYaw - torsoYaw) + (Config.head.maxYaw * (math.abs(yawDiff)/yawDiff) ) )
end
end
local function Update_View () -- Runs every frame
local head:Part = assignedCharacter.Head
local torso:Part = assignedCharacter.Torso
local displayHead:Part = assignedCharacter.DisplayHead
local headCF = head.CFrame
if math.abs(forwardPressed) == 1 or alignTorsoWithHead == true then
torsoYaw = math.lerp(torsoYaw,viewportVector.X,Config.movement.torsoLerpAlpha)
end
torso.CFrame = CFrame.new(torso.Position) * torso.CFrame.Rotation:Lerp(CFrame.fromEulerAnglesYXZ(math.rad(torso.Orientation.X), math.rad(torsoYaw), math.rad(torso.Orientation.Z)), Config.camera.lerpAlpha) --This is where the rotation would need to be added.
assignedCamera.CFrame = assignedEyes.WorldCFrame
end
Quite honestly I dont expect anyone to have the time to reply to this question, but I thought I would send it here anyways, just in case anyone can help.


