Player.CameraZoomDistance

Or, if you prefer to be consistent with the current API, Player.CameraZoomCurrentDistance

Here’s the problem: You can set the range at which a camera is allowed to exist with Player.CameraMaxZoomDistance and Player.CameraMinZoomDistance, but no way to get the current zoom distance nor set the current zoom distance. This is mildly infuriating because it is an incomplete API and I want to set the zoom distance incrementally for use with gamepad controls, while preserving the Camera+(Max||Min)+ZoomDistance API (because I could just set those numbers to the same thing when I want to zoom in and out, but like I said, it’s super hacky and won’t last as a widespread solution if lua code is used to add default gamepad control to games [which it should be {because if it isn’t, that would be really tacky}, to say the least] because not everyone’s idea of a game should fit the character or even have the same controls between them [unless ROBLOX is concerned that it will be “too hard” to remember which game you’re playing]).

This code will not actually do any zooming:

Camera = workspace.CurrentCamera
Stepped = game:GetService("RunService").RenderStepped
while true do
Camera.CoordinateFrame = Camera.CoordinateFrame*CFrame.new(0,0,-1)
Stepped:wait()
end

but something like this will:

Player = game.Players.LocalPlayer
Stepped = game:GetService("RunService").RenderStepped
while true do
if Player.CameraZoomDistance-0.05 < Player.CameraMinZoomDistance then
Player.CameraZoomDistance = Player.CameraMinZoomDistance
break
else
Player.CameraZoomDistance = Player.CameraZoomDistance-0.05
Stepped:wait()
end
end
12 Likes

Here I’ll help o:

You can set the camera zoom level by doing:

player.CameraMinZoomDistance = 30 player.CameraMaxZoomDistance = 30 wait() --tested and it needed a wait() player.CameraMinZoomDistance = 0.5 --default player.CameraMaxZoomDistance = 400 --default

You can get the current zoom level by doing:

dist = (workspace.CurrentCamera.CoordinateFrame.p - player.Character.Head.Position).magnitude

P.S. You nested like 4 brackets in your original post. Please split thoughts into paragraphs LOL.

12 Likes

Even though you can technically do this already (like doing what Mael suggested), I would still like to see this as it would be much easier to use.

I actually expected this to already be in the API and I had no idea that it didn’t.

1 Like

Here I’ll help o:

You can set the camera zoom level by doing:

player.CameraMinZoomDistance = 30 player.CameraMaxZoomDistance = 30 wait() --tested and it needed a wait() player.CameraMinZoomDistance = 0.5 --default player.CameraMaxZoomDistance = 400 --default[/quote]

[quote] I want to set the zoom distance incrementally for use with gamepad controls, while preserving the Camera+(Max||Min)+ZoomDistance API (because I could just set those numbers to the same thing when I want to zoom in and out, but like I said, it’s super hacky and won’t last as a widespread solution if lua code is used to add default gamepad control to games.

[/quote]

1 Like

Sorry to necropost an eight year old thread but im doing it because I believe they should add this still because its somehow still not here after eight whole years. While I understand you can get the camera in certain ways it makes zero sense for them to make specific properties tailored to setting the camera min and max and to not even have one displaying the current zoom. Having to do an overly specific formula just to get it seems stupid.

2 Likes

This formula is common, and it’s not complicated. It is used to get the distance between two vectors. You’ll find yourself using it in the future.

I know it’s not complicated i never said it’s not complicated i said it was oddly specific and annoying to get something so simple. it should just be a property since it already is one which isnt shown.

2 Likes

Gross negligence for a property literally every game should have available.

Im confused are you saying roblox is in gross negiligence for not letting us use it? I dont get what you are saying.

There should be a variable to just set the default zoom distance. There is a variable existing, roblox just doesn’t expose it for some reason.

I actually found if you copy the player scripts you can find all the camera code in there and set the default zoom.

It’s just annoying that something so incredibly simple has gone 17 years without being fixed, lol.