So, I’m attempting to make a survival game, and basically I want to limit the cameras Y axis rotation so you cant look down all the way, and you cant look up all the way either.
I’m rendering the legs of the character and want them to look good when looking down, and add to the overall realism of the game by limiting the movement of the camera.
I havent messed around with camera manipulation before, and I also dont want the camera to be locked down, I want the player to be able to freely look around as usual, just with the limits in place.
Also:
Thanks for the help, but it wasnt too helpful to me. I’ll certainly look into those though!
its easy, only took me 30 minutes to write 19 lines of code
-- client thing
-- I dont know where
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local MinAngle = math.rad(-50) --the lower the lower you can see
local MaxAngle = math.rad(81) -- extra setting for fun
RunService.RenderStepped:Connect(function()
local YAngle = Camera.CFrame:ToOrientation()
local CorrectedAngle = 0
if YAngle > MaxAngle then
CorrectedAngle = MaxAngle - YAngle
elseif YAngle < MinAngle then
CorrectedAngle = MinAngle - YAngle
end
Camera.CFrame *= CFrame.Angles(CorrectedAngle, 0, 0)
end)