How can I make my Camera Zoom Smoother?

I have this Camera Zoom Script right now

but as you can see it’s not smooth so I decided to look at Roblox’s New Camera Zoom Script from this update

it’s located at

after looking at it I’m not sure what to do with it

1 Like

Run the game in Studio then take a look in StarterPlayerScripts.PlayerModule.CameraModule.ZoomController.

1 Like

I’m not at home, so I can’t check that code myself to try helping with it, but I’m assuming it uses tweening and probably HeartBeat to make a smoother transition between camera zoom positions.

1 Like

Y̶o̶u̶ ̶c̶a̶n̶’̶t̶ ̶u̶s̶e̶ ̶T̶w̶e̶e̶n̶S̶e̶r̶v̶i̶c̶e̶ ̶f̶o̶r̶ ̶i̶t̶ ̶i̶f̶ ̶t̶h̶a̶t̶’̶s̶ ̶t̶h̶a̶t̶ ̶y̶o̶u̶ ̶m̶e̶a̶n̶.̶ ̶ ̶Y̶o̶u̶ ̶c̶a̶n̶’̶t̶ ̶o̶v̶e̶r̶r̶i̶d̶e̶ ̶i̶t̶ ̶l̶i̶k̶e̶ ̶t̶h̶e̶ ̶T̶w̶e̶e̶n̶ ̶M̶e̶t̶h̶o̶d̶s̶ ̶f̶o̶r̶ ̶G̶U̶I̶ ̶I̶n̶s̶t̶a̶n̶c̶e̶s̶.̶

And it wouldn’t be smooth because of the rapid input caused by using the MouseWheel

Sure you can Cancel the tween but I don’t think it would be as smooth as it could be

1 Like

This is false – you can totally override TweenService tweens by starting another tween on that same object with overlapping parameters. No need to explicitly cancel the previous tween either.

3 Likes

It won’t look wonky?

Right my bad.


I have read the Camera Script and I am sure that it’s not using TweenService @slimjim541

I’m not sure whether this would work in a gui, but this is how I did it in my model showcase game using the camera.

zoom = 8.5 -- or whatever you want it to start at
uis.InputChanged:Connect(function(input, gp)
	if gp then return end
	
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		if input.Position.Z == -1 then
			for i = 1, 10 do
				if zoom + 0.1 < 13 then
				zoom = zoom + 0.1
				wait()
				else
					break
				end
			end
		else
			for i = 1, 10 do
				if zoom - 0.1 > 4 then
				zoom = zoom - 0.1
				wait()
				else
					break
				end
			end
		end
	end
end)

The < 13 and >4 just sets limits so you can’t zoom in/out too far.
Then I use RenderStepped to actually set the camera’s CFrame.

runService.RenderStepped:Connect(function()
	camera.CFrame = camPart.CFrame * CFrame.new(0, 0, zoom)
end)

Once again, I’m not sure whether this would work in a gui but if you don’t want to use tween service then a for loop is probably the best option.

1 Like

“Tween” usually means a static animation, which this isn’t.
We modeled camera zoom as a critically damped spring to preserve continuity and avoid jarring velocity changes. That is the function of the ConstrainedSpring logic in ZoomController.

2 Likes

I see. Still at work, so I have yet to see it myself to see how it works, but @subcritical explained what method was used. Just gotta traverse that portion of the camera code to find the logic behind it to apply it for your needs.