First person, adjusting camera position

  1. What do you want to achieve? Bringing the camera more forward so it looks more realistic.

  2. What is the issue? How should i bring the camera depth more forward?

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to offset but it failed to do so, and i did look for solutions, but i did

-- important code

Camera.CameraSubject = Head

-- renderstep
RunService.RenderStepped:Connect(function(delta)
	hrp.CFrame = CFrame.lookAt(hrp.Position, Vector3.new(Mouse.Hit.X, hrp.Position.Y, Mouse.Hit.Z))
end)

Try this instead, this script will make it easier to adjust the camera depth. To adjust the depth, change the FirstPersonForwardDepth variable to a number. The higher the number, the more forward the camera will be to the rest of the body.

local Player = game.Players.LocalPlayer

local FirstPersonForwardDepth = 1 -- change these two variables to your liking
local LockPlayerInFirstPerson = true

if LockPlayerInFirstPerson == true then
	Player.CameraMode = Enum.CameraMode.LockFirstPerson
end

local function FirstPerson(Character)
	for Index, BodyPart in pairs(Character:GetChildren()) do
		if BodyPart.Name ~= "Head" and BodyPart:IsA("BasePart") or BodyPart:IsA("MeshPart") then
			BodyPart:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
				local Humanoid = Character:WaitForChild("Humanoid")
				
				if BodyPart.LocalTransparencyModifier == 1 then
					BodyPart.LocalTransparencyModifier = 0
					
					Humanoid.CameraOffset = Vector3.new(0, 0, -FirstPersonForwardDepth)
				else
					Humanoid.CameraOffset = Vector3.new(0, 0, 0)
				end
			end)
		end
	end
end

Player.CharacterAdded:Connect(function(Character)
	FirstPerson(Character)
end)

if Player.Character then
	FirstPerson(Player.Character)

	Player.Character.DescendantAdded:Connect(function()
		FirstPerson(Player.Character)
	end)
end
1 Like

I have tried the code you showed to me, i as well have a head/waist rotation local script,


and i want to keep the bobbing of the walking, like the original code, is there a way to patch this?

I don’t know if it will be compatible with my script (as it’s very basic anyways), but I’ll try my best. I’ll report back to you if I find a solution.

1 Like