CameraMinZoomDistance Greater Than 20 Disables Gamepad R3 Camera Zooming - Fixed Numbers

Steps:

  1. Open a new Roblox studio template or the Repro file below
  2. (ignore for Repro file) - Change the CameraMinZoomDistance (under StarterPlayer) to be greater than or equal to 20
  3. (ignore for Repro file) - Change CameraMaxZoomDistance to be greater than or equal to 20
  4. Connect a Gamepad controller/remote
  5. 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.

1 Like

This might be the same issue here:

I assume making a new bug report would get more eyes on it as the above bug report is marked as “Fixed” and it’s a year+ old.

Hi there, these fixed gamepad zoom levels are intentional as the default max zoom distance is quite large. If you want to change these for your own game, you can fork the playerscripts and change the gamepadZoomLevels value, but keep in mind that you’ll stop receiving playerscript updates.

1 Like

I’m confused by the reasoning despite hearing that the behavior is intentional, and thus making bug reporting null and making a feature request warranted. It’s unintuitive behavior.

Why not make the code a percentage of what the Min and Max are, so that it scales with whatever those change to? This would make things work exactly as they are now, without needing to fork the script to get what most would think would happen.


Not the best solution, but it’ll work for my situation, since I had to fork the same scripts for the exclude list for camera popping.

Forking playerscripts seems to be a necessary evil in Roblox game development. I get it, we can’t add all the features in the world to fit every game. I’d argue many things though, like scaling zoom based on a percentage would be good for all.


Also, thanks for the reply. Acknowledgement is more than half the battle for the developer community.

1 Like

The current default max zoom is 128 so scaling the current behavior of 20 as gamepad zoom max would be 16% of max zoom which is probably not the intended behavior for most people. Especially if a developer adjusts max zoom to something like 20, they wouldn’t expect the gamepad to only be able to reach 3.

I don’t actually disagree that the gamepad zoom should be able to reach the same values that a mouse scroll should be able to (i.e. 128), but that would be a behavior change so it has to be treated like a feature request.

1 Like