Making the camera follow the player's head

My game is reliant on it’s animations for it to look good and I want the camera to follow the player’s head as they’re moving with the animation.

I’m able to get the effect I want, but the problem I’m having is it breaks the shiftlock which is also needed for my game. The shiftlock still works with moving the camera around, but the player will no longer turn with the shiftlock and instead the player has to jump in order for them to turn at all with shiftlock on.

I’ve looked up videos and read things on the forum trying to find ways to fix this problem. However, most of them have mentioned making a completely different camera system or shiftlock system. If that’s the only way then I’ll have to do it, but is there an easier way to achieve this?

This is the effect I want:

This is the code I’ve been using to get the effect, but again it breaks the shiftlock and prevents the player from turning with it.

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

local target = character:WaitForChild("Head")

runService.RenderStepped:Connect(function()
	camera.CameraSubject = target
end)

There is an easier way to do it. Here is an example of how you could do it.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local rootpart = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")

game:GetService("RunService"):BindToRenderStep("CameraOffset", Enum.RenderPriority.Camera.Value - 1, function()
	local offset = (rootpart.CFrame * CFrame.new(0, 1.5, 0)):pointToObjectSpace(head.CFrame.p)
	hum.CameraOffset = offset
end)
1 Like

Almost forgot I made this post, but thanks! It worked and now it’s not as wonky anymore.

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