Change player's camera zoom without using FOV

Hi, I am currently try to make a 3rd person shooter game. I was wondering how to achieve such zoom without using FOV.
Note: The current zoom of player in the image is 2 after setting the CameraMinZoom = 2.

Something I thought about is to make a script that changes the CameraMaxZoom to be 2 when aiming, then returns it back to something like 15, but that ended by keeping the camera zoom at 2 without zooming out, which requires the player to zoom out manually. How can I achieve that automatically?

Thanks in advance and sorry if I couldn’t clarify well, my English isn’t good.

2 Likes

To clarify what I mean, that’s an example from roblox’s weapon kit:

1 Like
function setZoom(min,set,max)
	player.CameraMinZoomDistance=set
	player.CameraMaxZoomDistance=set task.wait(0.1)
	player.CameraMinZoomDistance=min
	player.CameraMaxZoomDistance=max
end

setZoom(5, 5, 5)
--setZoom(4.5, 9.5, 11)

Forces the current camera zoom to ‘set’ zoom, then it sets the possible ‘min’ and ‘max’ zoom distance.

1 Like

That actually worked! I guess you forgot to uncomment the last line, thank you! :smiley:

For anyone who’s looking at this, here’s the corrected form

function setZoom(min,set,max)
	player.CameraMinZoomDistance=set
	player.CameraMaxZoomDistance=set task.wait(0.1)
	player.CameraMinZoomDistance=min
	player.CameraMaxZoomDistance=max
end

setZoom(5, 5, 5) -- Zooms in
setZoom(11, 9.5, 11) -- Zooms out
setZoom(4.5, 9.5, 10) -- set it to your custom defaults

The first setZoom will zoom in the camera, the second one will zoom out, and the third will reset to default

Just showing different options with that.

setZoom(5, 5, 5) – locks the zoom at 5

setZoom(11, 9.5, 11) – ‘set’ has to be between ‘min’ and ‘max’ or the same as, this isn’t.
setZoom(11, 11, 11)? or setZoom(9.5, 9.5, 9.5)?

setZoom(4.5, 9.5, 10) – sets zoom at 9.5, can zoom in to 4.5 or out to 10

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.