Steps:
- Open a new Roblox studio template or the Repro file below
- (ignore for Repro file) - Change the CameraMinZoomDistance (under StarterPlayer) to be greater than or equal to 20
- (ignore for Repro file) - Change CameraMaxZoomDistance to be greater than or equal to 20
- Connect a Gamepad controller/remote
- Play the game in studio, and try to zoom the camera with R3
System Info:
- CPU: AMD Ryzen 7 4700U with Radeon Graphics
- Memory: 8GB
- GPU: AMD Radeon™ Graphics
Repro File:
ReproForNotZoomOnGamepad.rbxl (55.0 KB)
Expected behavior
The camera code should scale based on the min and max camera values that developers can set, not fixed to [0, 10, 20]. I go into more detail below.
As an aside, though, if this needs to be a feature request, I do not have access to post in that category. I’d be remiss to not mention this feature request: Allow developers to configure the default zoom distances for gamepads.
This issue and what that feature request asks for could be worked on together, but they are two different things. This bug asks for zooming to scale based on values of Min and Max, whereas the feature request asks for more control. I also find this bug report noting something that developers expect to happen, not a new feature. It’s a design flaw, but I digress.
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.