How to make outlast camera zoom system?

Basically you can zoom with scroll wheels

1 Like

Wrong category, this should be in the scripting support category.

I would try to store a variable called zoom and clamp it between 0 and 1, then increase or decrease that value depending on the scroll wheel, 0 being the minimum zoom amount and 1 being the maximum zoom amount.

Probably not the best way, but try it out.

You’d just need to detect which way the user is scrolling their mouse, so basically:

uis.InputChanged:Connect(function(t)
	if t.UserInputType == Enum.UserInputType.MouseWheel then
		if t.Position.Z > 0 then
			currentZoom = math.clamp(currentZoom + 0.1, 0, 1 - slider.Size.X.Scale)
		else
			currentZoom = math.clamp(currentZoom - 0.1, 0, 1 + slider.Size.X.Scale)
		end
	end
end)

You’d just need to set up a RenderStepped function to change the camera’s FOV to the currentZoom by doing

local fovcalc = (1 - currentZoom) * (minZoomFOV - maxZoomFOV) + maxZoomFOV

The formula maps the range [0, 1] to [maxZoom, minZoom]

Considering you’re trying to basically achieve the same result as