How to make Camera follow player's head

How can I make the camera follow my player’s head? I have a script that makes it so you can view the player’s body in first person, and the torso rotates with the camera. When I do this, I can see the back of my player in first person, because the camera is in a fixed position and does not move with the player. I need the camera to somehow rotate on an axis with the head or follow the head completely.


i don’t scripted too long, but if i remember we using local script in character with RunService.RenderStepped, example:

local offset = CFrame.new(0,0,0)*CFrame.Angles(0,0,0)
local body = 
game:GetService("RunService").RenderStepped:Connect(function(delta)
  workspace.CurrentCamera.CFrame=script.Parent.HumanoidRootPart.CFrame+offset
  -- we can change root part to torso
end)

hope it’s works.

So you can take an offset cframe and multiply it with the hrp cframe and itll always offset relative to the cframe. However im guessing the part of the character that moves is not the HRP but the upper torso, the hrp is invisible and fixed to the y axis.

This is kind of complicated and you might just end up making your own camera system.

Tbh its just easier to disable the roblox camera and then make your own controller (which is very simple dont get me wrong) so you can have a dynamic offset.

The only problem is that you do not have a reference cframe that is correctly rotated to match the actual upper torso cframe, the hrp cframe will not actually tilt with the character as i mentioned. You cant really use the UpperTorso as a reference because it will be affected by animations and such.

Here is what i can think of though, if i absolutely had to do it.


local yOffset = head.Position.Y - hrp.Position.Y

local offset = CFrame.new(0, yOffset, 0)

local noPitchCF = CFrame.fromMatrix(cam.Position, cam.CFrame.RightVector, Vector3.yAxis)

local camRelativeToNoPitch = noPitchCF:ToObjectSpace(cam.CFrame).Rotation

local pitch, _, _ = camRelativeToNoPitch:ToEulerAnglesXYZ()

local newCamCF = hrp.CFrame * CFrame.Angles(pitch, 0, 0)

newCamCF *= offset

cam.CFrame = newCamCF

The logic is to basically derive the cameras pitch and then create a new cframe which is rotated by pitch relative to HRP, and then translated in its local y axis by an offset which is equal to the intended vertical distance between the head and hrp.

1 Like

Can’t you just set the camera mode to lock first person. If not you’d have to change the cameras CFrame to heads CFrame every frame using run service but I don’t think that would be necessary

Im pretty sure doing that would make the camera not controllable by the user

depends on what you mean, try it and if it doesn’t work as you want I have other solutions that might work

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.