How can i make the head copy the rotation of the camera in first person?

How could I make the head’s neck joint have a rotation (maybe position) to copy the camera?
How could i also achive arm positioning to the server like this too? (linked video)

(1) ROBLOX How To Make A First Person System - Body Movement & Camera (READ DESC) - YouTube

i want to achieve something like this

You can use the lookAt() function with the head towards the position of wherever the head is looking at with ViewportPointToRay(). That’s how I’d do it, anyway.

You could actually find the rotation of the camera on whatever axis and copy it to the character’s head, firing constantly with the .RenderStepped() event.

May have to rename UpperTorso in the script.. I really don’t mess with anything other than R15.

task.wait(1) --LocalScript in StarterCharacterScripts

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local Camera = workspace.CurrentCamera

local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Torso = Character:WaitForChild("UpperTorso")
local Waist = Torso:WaitForChild("Waist")

local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0
Neck.MaxVelocity = 1/3

local PlayerMouse = Player:GetMouse()
RunService.RenderStepped:Connect(function()
	local CameraCFrame = Camera.CFrame
	local Point = PlayerMouse.Hit.Position

	if Camera.CameraSubject:IsDescendantOf(Character) then
		local Distance = (Head.Position - Point).magnitude
		local Difference = Head.Position.Y - Point.Y
		local Direction = (Head.Position - Point).Unit

		local HeadRotation = CFrame.Angles(-math.atan(Difference 
			/ Distance) * 0.5, Direction:Cross(Torso.CFrame.LookVector).Y * 1, 0)
		local WaistRotation = CFrame.Angles(-math.atan(Difference 
			/ Distance) * 0.5, Direction:Cross(Torso.CFrame.LookVector).Y * 0.5, 0)

		Neck.C0 = Neck.C0:lerp(NeckOriginC0 * HeadRotation, 0.25)
		Waist.C0 = Waist.C0:lerp(WaistOriginC0 * WaistRotation, 0.25)
	end
end)

Did this so long ago it was hard to find in my notes and snippets.
Really turned out way better than I was thinking it would.

this works for me:

--!strict

local run_service = game:GetService("RunService") :: RunService
local attachment : Attachment?

run_service.PreRender:Connect(function()
	if not attachment then return end
	
	local camera = workspace.CurrentCamera
	assert(camera)
	attachment.CFrame = CFrame.new(attachment.Position) * camera.CFrame.Rotation
end)

local function character_added(model : Model)
	local head = model:FindFirstChild("Head") :: BasePart
	local humanoid_root_part = model:FindFirstChild("HumanoidRootPart")
	attachment = Instance.new("Attachment")
	attachment.Parent = humanoid_root_part

	local ik_control = Instance.new("IKControl") :: IKControl
	ik_control.Parent = head
	ik_control.Target = attachment
	ik_control.ChainRoot = humanoid_root_part
	ik_control.EndEffector = head
	ik_control.Type = Enum.IKControlType.Rotation
	ik_control.Weight = .5
	
end

local player = game.Players.LocalPlayer
assert(player)

player.CharacterAdded:Connect(character_added)
player.CharacterRemoving:Connect(function()
	assert(attachment)
	attachment:Destroy()
	attachment = nil
end)

if player.Character then character_added(player.Character) end

the script requires some additional touches to prevent looking backwards :smiley:.
this is fixed by setting ik_control.Weight = .5

Is there a way for this to work with limbs?

Maybe, did you try it.. It looks perfect. Just like how that should look and act.
Like I said even I was shocked at how well that turned out.

i tried it and it rotates the head sideways (z axis)

It’s for an R15.. it look totally realistic. Even the body twists a bit with the movement. Not sure how that would ever be fully used .. not really into frame loops like that, but it was part of test I was doing back then. I’m not even sure that could be applied to just to the head as it’s all basically reacting to the movement.

Found one.

char.Humanoid.CameraOffset = (char:WaitForChild("HumanoidRootPart").CFrame 
	+ Vector3.new(0, 1.5, 0)):PointToObjectSpace(char:WaitForChild("Head").Position)

From: First person camera following the head
And then someone has it perfect in one line … :man_facepalming:

1 Like