Camera Facing player?

I hope this has not been asked before, my apologies if I created a similar topic.
I’m trying to make the camera face the player:

game:GetService("RunService").RenderStepped:connect(function()

	local Camera = workspace.CurrentCamera
	Camera.CameraType = Enum.CameraType.Scriptable
	
	Camera.CoordinateFrame =  CFrame.new(Vector3.new(char.HumanoidRootPart.Position.X + -3 , char.HumanoidRootPart.Position.Y -1,char.HumanoidRootPart.Position.Z + 8), char.Head.Position) * CFrame.fromEulerAnglesXYZ(0,0,0.1)
end)

However: The camera is not facing the character’s head when the character turns:
https://gyazo.com/9f38c3cf25994eefacde624c53ca0503
The LookAt Argument is char.Head.Position though, did I do something wrong?

I’d like to perform something like this: (From Selfie Stick free model)
https://gyazo.com/1e96e63a7e7ff565802b97d20ed386ee

The selfie stick uses a camera part inside, it’s LookAt Argument is also the head and it works:

 CFrame.new(script.Parent.cam.Position, game.Players.LocalPlayer.Character.Head.Position)
5 Likes

Probably the simplest way to do this is to start at the head’s CFrame, translate it forward a couple studs, and turn it around with CFrame.Angles. I don’t think there’s any need to create a new CFrame beyond that:

character.Head.CFrame -- start at the head
	* CFrame.new(0, 0, -5) -- move camera forward
	* CFrame.Angles(0, math.pi, 0) -- turn it around

The other way of doing it is probably welding a part identical to the head but reversed, and setting the camera type to Attach, with the CameraSubject set to that new part.

If you think this makes the camera too unstable, you can instead attach the camera to the humanoid root part instead:

character.HumanoidRootPart.CFrame -- start at the root
	* CFrame.new(0, 0, -5) -- move camera forward
	* CFrame.Angles(0, math.pi, 0) -- turn it around
	+ Vector3.new(0, 1.5, 0) -- to account for head offset
4 Likes

Here’s my Solution:

game:GetService("RunService").RenderStepped:connect(function()
    local Camera = workspace.CurrentCamera
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = CFrame.new((char.HumanoidRootPart.CFrame * CFrame.new(-3, -1, -8)).Position, char.Head.Position) * CFrame.fromEulerAnglesXYZ(0,0,0.1)  end)

I CFramed the camera relative to the humanoidrootpart like you did, and used that cframe to face the camera to the head. I hoped this helped :slight_smile:

6 Likes

I think both solutions work, thanks!

2 Likes