How would I make this camera peek smoother?

Hi I am working on a camera peeking / tilt system, but I am a little unsatisfied with my results
This is my progress at the moment

As you can see when the camera is done tilting it abruptly stops, I want to change this so it can smoothly stop, how would I do this?

This is the script that manages the camera tilt

game:GetService("RunService").RenderStepped:Connect(function()
	if Q == true then
		Val = math.clamp(Val + 0.75,0,10)
		Camera.CFrame = Camera.CFrame * CFrame.Angles(0,0,math.rad(Val))
	end
	if E == true then
		Val = math.clamp(Val - 0.75,-10,0)
		Camera.CFrame = Camera.CFrame * CFrame.Angles(0,0,math.rad(Val))
	end
	if Tilting == false then
		Val = Val / 1.1
		Camera.CFrame = Camera.CFrame * CFrame.Angles(0,0,math.rad(Val))
	end
end)

You can try tweening the camera rotation

Try this out,

Camera.CFrame = Camera.CFrame:Lerp(Camera.CFrame * CFrame.Angles(0,0,math.rad(Val)), math.min(deltaTime * 2, 1)))

You can get the deltaTime here,
game:GetService("RunService").RenderStepped:Connect(function(deltaTime) and it’s basically used to prevent FPS from messing up the result. You can also play around with math.min() formula to make it feel better. Haven’t tested it so not sure if it’s gonna work properly.

1 Like

Try TweenService with EasingStyle “Sine”