I am making a shooter and when the person right clicks, the camera moves from 6 studs away to 3 studs from the player. (Just zooms in.) I do this simply by changing the maxviewdistance. However, It moves the camera instantly. When the player stops right clicking to zoom in, I change the view distance back to 6 which actually does move smoothly. How would I get it to go smoothly when they initially zoom in?
Iāve written a simple function for you, it should work. Just pass in the value you want the FOV to be set to, along with the speed of the tween.
local camera = workspace.CurrentCamera
local tween_service = game:GetService("TweenService")
local function Tween_FOV(value, speed)
local tween_info = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = tween_service:Create(camera, tween_info, {FieldOfView = value})
tween:Play()
end
Thanks although I am not using FieldOfView. I am using the distance between the player and the camera. So when they are playing the distance the camera is from them is 6 studs away, and then when they zoom in its now 3 studs away. I use the cameraviewdistances to do it but it doesnāt zoom in smoothly.
So in that case change ācameraā to the LocalPlayer where I create the new tween object, then change āFieldOfViewā in the table to āCameraViewDistanceā (or the correct name of the property of Player)
Iām not entirely sure if TweenService supports that property, but itās definitely worth a shot.