I'm creating a first person game where it is crucial to be able to look straight up and straight down, but the maximum is 80 degrees. So, I looked inside the root camera script, found the numbers, but it seems that the way Roblox's camera works is hard coded to be max 80 degrees without breaking down. So I'm making a new camera script and have been working off of this for about a day now, with no luck.
local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = workspace.blockHold.PreCreated.Part camYaw = 90 camYZ = 0 _G.XMouse = 0 _G.YMouse = 0 local UserInputService = game:GetService("UserInputService") UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter UserInputService.InputChanged:connect(function(inputObject) if inputObject.UserInputType == Enum.UserInputType.MouseMovement then _G.XMouse = inputObject.Delta.x _G.YMouse = inputObject.Delta.y camYaw = camYaw + _G.XMouse camYZ = camYZ + _G.YMouse if camYZ >90 then camYZ=90 end if camYZ <-90 then camYZ=-90 end camera.CoordinateFrame = CFrame.new(0,0.1,0) *CFrame.Angles(math.rad(math.cos(math.rad(camYaw))*-camYZ),math.rad(-camYaw),math.rad(math.sin(math.rad(camYaw))*-camYZ)) end end)
The script almost works, but looking in certain directions rotates the camera oddly.
Any ideas of what I'm doing wrong? I've been slightly tweaking this code for a while but I'm now just completely stuck. The local script is named CameraScript and is in StarterPlayer>StarterPlayerScripts. I also don't really know trig if that clears anything up. Thanks in advance for any changes you might have.