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
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.
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.
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.
I agree, there should be a way to read the current zoom level and to directly set the zoom level in any of the available CameraType modes.
Right now if you tween the camera to a position you want it to be, then restrict the camera for a few frames with player.CameraMinZoomDistance and player.CameraMaxZoomDistance then the camera snaps into the previous zoom level and then back to the restricted level. This doesn’t look very nice, especially after a smooth camera tween. (At least this happens when you switch the camera CameraType to Enum.CameraType.Track)
This seems like such an obvious feature to have as well…
I believe that this property won’t be a thing because playermodule controls the camera including zoom.
Edit: i kinda misunderstood the post. I like the idea of letting developers set zoom official way, not just making the property readable only
by official way, i meant you don’t need to modify playermodule
You can accomplish it by adding two functions in playermodule aka set and retrieve zoom. And you can implement those by seeing how does zoom work in cameramodule
^ that’s a little advise for everyone if you need that