How can I limit the vision of my player so that he cannot look at his legs?
I made the player in first person using:
player.CameraMode = Enum.CameraMode.LockFirstPerson
but now I would like to limit your visual field so that you cannot look at your legs in the first person
I would like to put a limit when looking down and a limit when looking up, in the reference images it is understood a little better what I want to achieve, someone could give me a hand please
You should be able to clamp the camera’s rotation using :BindToRenderStep. You’d also probably have to use trial and error to define the lower bound as I’m not too sure how to do the math.
Try this, parent to StarterCharacterScripts:
local runService = game:GetService('RunService')
local torso: BasePart = script.Parent:WaitForChild('Torso')
local camera = workspace.CurrentCamera
local cameraClampMin = -30
local cameraClampMax = 90
local function clampOrientation()
local cframe = workspace.CurrentCamera.CFrame
local rX,rY,rZ = cframe:ToOrientation()
local clamp = math.clamp(math.deg(rX), cameraClampMin, cameraClampMax)
workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.p) * CFrame.fromOrientation(math.rad(clamp), rY, rZ)
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA('BasePart') and v.Name ~= 'Torso' then
v.LocalTransparencyModifier = 0
end
end
end
runService:BindToRenderStep('ClampCamera', Enum.RenderPriority.Camera.Value, clampOrientation)