I’m trying to create the gradual zoom effect that you can find on the crossbow for a custom swep. This is the code I have so far that controls it;
zoomed = false defZoom = 0 function SWEP:Deploy() defZoom = self.Owner:GetFOV() end function SWEP:Think() if zoomed then self.Owner:SetFOV(math.max(self.Owner:GetFOV() - 2, 20), 0) else self.Owner:SetFOV(math.min(self.Owner:GetFOV() + 2, defZoom), 0) end end function SWEP:SecondaryAttack() zoomed = not zoomed return false end
However, the zooming in and out is really buggy and dysfunctional. Is there a better way of doing it?