What do you want to achieve?
I want to limit the range of motion of a first-person camera. I don’t want a player to be able to look straight down or up.
What is the issue?
I am currently working on a horror game and have a script that allows the player to see their body in first person. This works well, however, if a player were to look straight down they can see the top of their body which ruins the effect. How can I limit the range of motion for the first-person camera?
What solutions have you tried so far?
I have searched the internet and have not found anything.
Pictured below is what the player can see if they look straight down.
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
player.CameraMaxZoomDistance = 0.5
camera.FieldOfView = 100
humanoid.CameraOffset = Vector3.new(0, 0, -1)
for childIndex, child in pairs(character:GetChildren()) do
if child:IsA("BasePart") and child.Name ~= "Head" then
child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
child.LocalTransparencyModifier = child.Transparency
end)
child.LocalTransparencyModifier = child.Transparency
end
end
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
player.CameraMaxZoomDistance = 0.5
camera.FieldOfView = 110
humanoid.CameraOffset = Vector3.new(0, -1, -1)
for childIndex, child in pairs(character:GetChildren()) do
if child:IsA("BasePart") and child.Name ~= "Head" then
child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
child.LocalTransparencyModifier = child.Transparency
end)
child.LocalTransparencyModifier = child.Transparency
end
end