Orbital Camera around a planet

Hi I’d like to make a camera that can be moved around a sphere with a mouse, how can I do this?

1 Like

Could you explain a bit more what you want?

1 Like

Yeah sure, so what I’m trying to do is a player clicks on a sphere part and their camera focuses on it and they can move the camera around the sphere when holding down their mouse and they can use the scroll wheel to move their camera closer to the sphere or further away.

1 Like

You can set the camera’s CameraSubject to the part you want it to be attached to.

local RNS = game:GetService("RunService")

local part = -- insert part
local camera = workspace.CurrentCamera

RNS.RenderStepped:Connect(function()
	camera.CameraSubject = part
end)
1 Like

I need to be able to make it go closer to the sphere + further with scroll wheel and be able to be moved around the sphere with their mouse.

1 Like

That’s what the code does though.

1 Like

Here’s a question, what is your sphere (is it a model? part? etc.)?

1 Like

It is a part with a size of 2048

It works but can I up the zoom out distance cause it starts with you being inside the sphere and you can’t zoom out enough.

1 Like

You can try to just do this :

workspace.CurrentCamera.CameraSubject = --YOURPART

And after put in the StarterPlayer setting a higer distance for the zoom and zoom out !
image

2 Likes

Alright thanks, is there a way to make them start on a certain zoom in distance?

1 Like

You can change the CameraMinZoom (e.g. 2048) and CameraMaxZoom (e.g. 3000) to a high value. This makes sure that you don’t have to scroll insanely hard just to see the sphere.

2 Likes

Yes it is the best way ! :+1:
igore this : zfiejgug

2 Likes

Thanks that works, is there also a way to change this during gameplay for smaller planets and celestial bodies?

1 Like

You put a script that change the CameraMin and Max zoom when you change planet !

1 Like

I have tried changing the starter player zoom properties during gameplay but it doesn’t change anything sadly.

1 Like

Show me your script I think I can help !

This is a test at the moment. I thought that’s how you’d do it.

script.Parent.CameraMaxZoomDistance = 1
script.Parent.CameraMinZoomDistance = 0.1
1 Like

Ok I got it try this, you will understand !

script.Parent.CameraMinZoomDistance = 0.1
script.Parent.CameraMaxZoomDistance = 1
1 Like

I don’t think it works, I think there’s a different way of doing this but I’m not sure.

1 Like