360 DEGREES Camera View

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? :happy1:


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 :shock:
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:

For each frame:

  1. Poll mouse movement using UserInputService:GetMouseDelta() and add that to a rotation variable.
  2. Calculate the camera position based on the characters head position, camera orbit distance, and the rotation value. It might look like this;
ourCameraPosition = head.Position + (orbitDistance * Vector3.new(
math.sin(math.rad(rotation.X)), 
math.sin(math.rad(rotation.y)), 
math.cos(math.rad(rotation.X))))

(note that it may not look exactly like that, I’m pulling this straight out of my head)

  1. 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 :wink:

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.

  1. There needs to be a CFrame for rotation of the camera. It will show how the camera is oriented around a point
  2. Get user input (MouseDelta works fine for this)
  3. 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.
  4. Offset the Rotation CFrame for the position of the CameraSubject.
  5. 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.

7 Likes

Thank you so much! :happy4: This is so cool! I thought it was impossible!
:star2: T h e m o r e y o u k n o w! Thank you - Sincerely, @oscoolerreborn

1 Like

Sorry if me messaging you is getting annoying but…
I have a few questions! What does ‘SubjectPosition’

mean,
what does ‘SmoothCamera’

mean and
the S and qW in

mean? I do not fully understand, can you please explain :sad:?

Did you ever get this? I’m still kind of confused on how I can get a 360 camera to work.