Allow developers to configure the default zoom distances for gamepads

As a Roblox developer, it is currently too hard to adjust the default zoom distances for gamepad inputs to provide a streamlined experience. Currently, controllers are limited to three different zoom levels (close, very close, and first-person). As you can see in the video below, the current zoom distances are inadequate for a pleasant viewing experience:

In the video, the low-visibility of the player’s surroundings was depicted.

Here’s an example where the player is at a comfortable zoom distance:

I understand that StarterPlayer.MinZoomDistance can be used, however, it does not suit my use case.

9 Likes

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

4 Likes

This is a problem for our game Realistic Hand RP 🖐🤏 Without VR - Roblox. Support for custom gamepad zoom distances are among the many modifications we have had to make to the PlayerModule.

2 Likes

agree, this would help a lot and i don’t see a reason not to add it

2 Likes