Camera fully follow head

Yo, i’m thinking how I could do that the current Camera is fully follow the head, position and rotate, i already done the y position

here the script

local plr = players.LocalPlayer
local cam = workspace.Camera
local char = plr.Character

runservice.RenderStepped:Connect(function(deltaTime)
local pos = cam.CFrame.Position
local camcf = CFrame.new(pos.X, char.Head.CFrame.Position.Y, pos.Z)
cam.CFrame = camcf * cam.CFrame.Rotation
end)
2 Likes

technically its working, but it’s janky and it is following every movement of the head, i don’t want that, only to up and down movement (sorry i forgot to specify)

3 Likes

You can set the Camera.CameraSubject to the head of the Character.

After, you can adjust the CameraType to “Attach”

For more CameraType Enum’s, look here: CameraType | Documentation - Roblox Creator Hub

I hope this is your solution.
Thank you

2 Likes

CameraSubject can work but it give other problems because we change it into a part instead of the humanoid and because i want to do other things based on the position

2 Likes

Could you further explain in detail the issue and the desired outcome you would like?

2 Likes

the red triangle is currently what i have
the blue triangle is what i want to achieve

3 Likes

Ok, I think I might understand now.

You are wanting it the camera’s rotation to match the head’s rotation?

Like, if the player flipped then it would make the camera flip with it, aligned with the player’s head?

1 Like

what do you want exactly? do you want it to follow the head’s orientation?

1 Like

yes, that what i want to achieve just by changing the camera CFrame

2 Likes
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
local character = player.Character

runService.RenderStepped:Connect(function()
	local head = character.Head
	local x,y,z = head.CFrame:ToOrientation()
	camera.CFrame *= CFrame.Angles(0,0,z)
end)

try this, not sure if this is what you want

1 Like

I’ll try it tomorrow as fast i can, inkling put you as solution if it is

1 Like

it’s turning the whole character

3 Likes

im using the script that you provided but there is a problem, when i play the animation and the camera is too close from the character, the camera start spinning in a direction and the position get changed from the position before playing the animation

sorry for being late to response

1 Like

your current script is broken when zooming in

for :

Try this. If this is not what you want, try sending me a video or something of what you want.

i want to achieve this :

thanks to my friend for the footage

1 Like

sorry for this really really late response, but with the script that you gave me, the camera isn’t even following the head and you can’t look down

footage here :

Have you tried my script

Characterss30

To make sure I understand, I actually have something similar to what you are looking for I believe, are you simply trying to make it so if you rotate your camera, the head part will follow instead of turning the entire player instance?

no, what i want is that the camera follow the rotation of the head, like for example the camera do a spin when the player doing a roll by following it

You can use your character’s neck (Motor6D), because it gets animated when animation plays.

local OldCamCF
local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local neck = player.Character.Torso.Neck

runService.RenderStepped:Connect(function()
	local NewCamCF = neck.Transform
	if OldCamCF then
		local _, _, Z = NewCamCF:ToOrientation()
		local X, Y, _ = NewCamCF:ToObjectSpace(OldCamCF):ToEulerAnglesXYZ()
		game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(X, Y, -Z)
	end
	OldCamCF = NewCamCF
end)

From what i see you want to limit camera movement in one axis, soo you can rewrite your camera CFrame by their 2 components and replace third one with your angle, remember it may not work well with 3rd person soo try to use this behavior only when player is in first person

2 Likes