Hey,
How would I go about locking the camera view so you can’t look down at the floor or up at the roof and can only look forward (they’re in first person) and up-down a few degrees?
Discord: lukemango#5552
Thanks,
Luke
Hey,
How would I go about locking the camera view so you can’t look down at the floor or up at the roof and can only look forward (they’re in first person) and up-down a few degrees?
Discord: lukemango#5552
Thanks,
Luke
local maxrot = math.rad(30)
game:GetService("RunService").RenderStepped:Connect(function()
local ccf = cam.CFrame
local xr,yr,zr = ccf:ToEulerAnglesXYZ()
local nxr = math.clamp(xr,-maxrot,maxrot)
if xr~=nxr then
cam.CFrame = CFrame.new(ccf.Position)*CFrame.Angles(nxr,yr,zr)
end
end)
On mobile so no tabbing.
Thankyou, i’ll test this out!
<3
Tried that out, but it only forces them to look left,
how can I change it so they look 90 degrees right instead?
Just add 90 degrees to yr used in the CFrame.Angles …
WDYM 90 degrees left or right? The code I gave you limits the camera on the x, not y-axis.
A bit of a necrobump, but OK.
local maxrot = math.rad(30)
game:GetService("RunService").Heartbeat:Connect(function()
local cam = workspace.CurrentCamera
local ccf = cam.CFrame
local xr,yr,zr = ccf:ToOrientation()
local nxr = math.clamp(xr,-maxrot,maxrot)
if xr~=nxr then
cam.CFrame = CFrame.new(ccf.Position)*CFrame.fromOrientation(nxr,yr,zr)
end
end)
It’s a good script, although when I reach the max height the camera is a bit shaky.