Is there a way to create a camera script where if you can turn your camera 360* All the way round instead of stopping once you look too far up or down! No matter if the camera turns upside down, can someone help me with this?
The video shows what I mean!
Does anyone know how? I looked around The Devforum and Youtube but there was nothing that could answer this question!
You don’t have to answer it, any feedback is appreciated, even if you say its not possible
Thank you for reading - Sincerely, @oscoolerreborn
With the built-in Roblox camera, unfortunately no. A comment in the BaseCamera module explains why:
-- Note: DotProduct check in CoordinateFrame::lookAt() prevents using values within about
-- 8.11 degrees of the +/- Y axis, that's why these limits are currently 80 degrees
Doing what you need would require a rewrite of the camera system, but don’t do that. More realistically, what you’d want is to create your own camera script which isn’t actually that hard. There are some decent starting points / guides out there (this is a decent one). It’s still a relatively involved process, and because of that I’m not going to give a script, but I will help outline what a script might look like:
(note that it may not look exactly like that, I’m pulling this straight out of my head)
Finally, set the camera’s CFrame to be CFrame.lookAt(ourCameraPosition, head.Position), which will automatically get the angle we need.
I’d recommend looking into CFrames and manipulating them for a better understanding of CFrames. Also, by using some of the techniques you can learn from these resources you’ll get an understanding of why certain things work, like why math.cos and math.sin need math.rad. At least I did
Yes there is. I actually found this in a bug of one of my CameraScripts.
Basically I used the CFrame.new() method to create some smooth rotation and ended up with this.
There is a hefty amount of code for this so instead I will just give you a rundown on how it works.
There needs to be a CFrame for rotation of the camera. It will show how the camera is oriented around a point
Get user input (MouseDelta works fine for this)
Rotate the CFrame using CFrame.Angles or any other method of rotation. I use the CFrame.new(x,y,z,qX,qY,qZ,qW) method as it works really well and takes care of upside down cases.
Offset the Rotation CFrame for the position of the CameraSubject.
Translate the CFrame backwards and position the Camera at that CFrame. I created function with handles scrolling of the mouse so that I can scroll in and out.
--1
local CameraRotationMatrix = CFrame.new()
--2
local MouseDelta = UserInputService:GetMouseDelta() * -GameSettings.MouseSensitivity
--3
CameraRotationMatrix *= (CFrame.new(0,0,0,rad(MouseDelta.Y * S),0,0,qW))
CameraRotationMatrix = (CFrame.Angles(0,rad(MouseDelta.X / 16),0) * CameraRotationMatrix)
--4
CacheCFrame = CameraRotationMatrix + SmoothCamera.CameraSubject.Position -- CacheCFrame is just a placeholder I used for storing CFrames. I use it in other places of my code too.
--5
Camera.CFrame = CFrame.lookAt(
SubjectPosition + (CacheCFrame.LookVector * -SmoothCamera.CameraDistance), -- Translate backwards,
SubjectPosition,
CacheCFrame.UpVector -- Keep Camera oriented correctly to the CFrame (without this Camera will stay always facinig up normally)
)
Hopefully this helps
Note: You can use Cartesian Coordinate system if you want to however Polar Coordinate system for deciding the Camera location is much easier to do.
Another note: Input is reverse when it is upside down.