I recently created a script that makes the upper torso move up and down according to the camera’s direction. It works great but the problem is that the camera itself doesn’t follow the head’s position when looking up or down, this causes it to look very weird when looking high up or down.
Is there a way to keep the camera’s position the same as the head’s without needing to create my own first person camera? the camera is already set to LockFirstPerson.
I’m modifying the waist Motor6D to achieve the effect:
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local char = plr.Character or plr.CharacterAdded:Wait()
local upperTorso = char:WaitForChild("UpperTorso")
local waist = upperTorso:WaitForChild("Waist")
local y = waist.C0.Y
RunService.RenderStepped:Connect(function()
if waist then
local camDirection = cam.CFrame.LookVector
local angle = math.deg(camDirection:Angle(char:WaitForChild("HumanoidRootPart").CFrame.LookVector, cam.CFrame.RightVector))
waist.C0 = waist.C0:Lerp((CFrame.new(0, y, 0) * CFrame.Angles(math.rad(math.clamp(-angle, -70, 70)),0,0)), 0.5/2)
end
end)
Something i found while trying this: setting the cameraSubject to the head solves the spazzing issue, but now i cant rotate the camera and character around
This converts the head’s position from world space to the HRP’s object space, which is the same space that the CameraOffset uses, and sets the resulting position as the offset, putting the camera where the head is.