Camera Not Following Player Head Rotation

Okay so here a very fast question:
How can I have the camera to rotate with the player head?

For example: The player dies, ragdoll is activated and the player falls, camera follows player head movement but not rotation. That is the problem

Thanks!

So, you’re not trying to make the head follow the camera, but vice versa?

Exactly. You may have seen some games that if you die, you fall and the camera follows the head movement and rotation. I forgot to say, but my player is locked in first person.

hmmm, I’m thinking a LookVector from the player head to then change the camera to the LookVector’s direction.

Set Camera.CameraType to Scriptable and then every RenderStepped set the Cameras CFrame to be the Heads CFrame. This effect can cause players to become dizzy and disoriented however if their ragdoll falls down a hill or rolls over rapidly, so be careful with it.

1 Like

That’s exactly what I want to achieve! Thanks!

Quick question to it:

I have this now:

local player = game.Players.LocalPlayer
local char = player.Character
local head = char:WaitForChild("Head")

local RunService = game:GetService("RunService")

local RATE_PER_SECOND = 2

RunService.RenderStepped:Connect(function(step)
	local increment = RATE_PER_SECOND * step
	
	local pos = head.CFrame
	local lookAt = head.CFrame
	local cameraCFrame = CFrame.new(pos, lookAt)
	workspace.CurrentCamera.CFrame = cameraCFrame
end)

but that doesn’t rotate the camera to the player head rotation, only the movement of the head (if the player walked thus.). did I do something wrong?

You don’t need to use lookAt, just straight up set the Camera CFrame to the heads CFrame value. There is no need to scale by delta time here either.

Camera.CFrame = Head.CFrame
1 Like

Still not working:

Name = game.Players.LocalPlayer.Name -- Get's the PlayerName
Head = game.Workspace:FindFirstChild(Name):WaitForChild("Head") -- Get's the Player head in Workspace

local RunService = game:GetService("RunService") -- Defines RunService

RunService.RenderStepped:Connect(function()
	workspace.CurrentCamera.CFrame = Head.CFrame -- Should set the Camera CFrame to the head, but that is not happening
end)

Have you set the CameraType to Scriptable?

My copy cut if off, but yes I did. Here is the full script since it was cut off:

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable -- Sets CameraType to Scriptable
Name = game.Players.LocalPlayer.Name -- Get's the PlayerName
Head = game.Workspace:FindFirstChild(Name):WaitForChild("Head") -- Get's the Player head in Workspace

local RunService = game:GetService("RunService") -- Defines RunService

RunService.RenderStepped:Connect(function()
	workspace.CurrentCamera.CFrame = Head.CFrame -- Should set the Camera CFrame to the head, but that is not happening
end)

Sometimes CameraType is not correctly set, check if the CameraType in the Camera instance is Scriptable. If it is scriptable then you may need to set the CameraSubject to the head as well.

It doesn’t set it to scriptable, but to Custom. Is there any reason for this?

Try to set it after you have waited for the head to exist. I also recommend using Player.Character over your method.

local Character = Player.Character or Player.CharacterAdded:Wait() -- if character does not exist we will wait for it to exist.

Well I’m completely lost. I don’t know it anymore.

local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() -- if character does not exist we will wait for it to exist.
Head = Character:WaitForChild("Head") -- Get's the Player head in Workspace

local RunService = game:GetService("RunService") -- Defines RunService

workspace:WaitForChild("CurrentCamera").Subject = Head
workspace:WaitForChild("CurrentCamera").CameraType = Enum.CameraType.Scriptable -- Sets CameraType to Scriptable

RunService.RenderStepped:Connect(function()
	workspace.CurrentCamera.CFrame = Head.CFrame -- Should set the Camera CFrame to the head, but that is not happening
end)

My script is in StarterPack, I checked on errors or anything else. It just doesn’t work

Move it to StarterPlayerScripts and try again.

I almost dont dare to say it, but still not working.

what about starter character scripts? that might work.

Also doesn’t work sadly. I’m out of ideas.

so, its a local script and its inside character scripts / player scripts?

1 Like