I highly support this. In my process to better my game’s camera, I’ve noticed that zooming in/out on Roblox has not been great for gamepads. After some digging into the PlayerScripts → PlayerModule → Camera Module → BaseCamera script, I found the following:
Code (click to open drop down)
-- cycles between zoom levels in self.gamepadZoomLevels, setting CameraToSubjectDistance. gamepadZoomLevels may
-- be out of range of Min/Max camera zoom
function BaseCamera:GamepadZoomPress()
-- this code relies on the fact that SetCameraToSubjectDistance will clamp the min and max
local dist = self:GetCameraToSubjectDistance()
local max = player.CameraMaxZoomDistance
-- check from largest to smallest, set the first zoom level which is
-- below the threshold
for i = #self.gamepadZoomLevels, 1, -1 do
local zoom = self.gamepadZoomLevels[i]
if max < zoom then
continue
end
if zoom < player.CameraMinZoomDistance then
zoom = player.CameraMinZoomDistance
if FFlagUserFixGamepadMaxZoom then
-- no more zoom levels to check, all the remaining ones
-- are < min
if max == zoom then
break
end
end
end
if not FFlagUserFixGamepadMaxZoom then
if max == zoom then
break
end
end
-- theshold is set at halfway between zoom levels
if dist > zoom + (max - zoom) / 2 then
self:SetCameraToSubjectDistance(zoom)
return
end
max = zoom
end
-- cycle back to the largest, relies on the fact that SetCameraToSubjectDistance will clamp max and min
self:SetCameraToSubjectDistance(self.gamepadZoomLevels[#self.gamepadZoomLevels])
end
That code above has a comment that’s related to this: (line 71 of the same script)
self.gamepadZoomLevels = {0, 10, 20} -- zoom levels that are cycled through on a gamepad R3 press
So, I think that the 0,10,20
are the three default zoom distances. It looks like those numbers don’t change based on the Min/Max distance for the camera; and there’s no way to have more than three options of camera distances.
I’d love to see the ability to specify how granular the zooming presses can be, as well as the numbers updating based on the min and max I set.
I say that the zoom numbers do not change as in my current project, they do not seem to. My max is 60
and my min is 20
. And, I don’t seem to be able to zoom in and out at all with a gamepad (specifically tested an Xbox one controller) connected. I assume this to be because that 0,10,20
does not change, but the code is respecting the 20
minimum limit for the camera distance.
Here's a video of the zooming not working with my gamepad (click to open drop down)
https://www.youtube.com/watch?v=rFZAkp5FxMg