How to increase FOV when shooting?

How do you make it that when you shoot it increasing fov but lerps back into the default fov

Return the FOV in this hook. You can use Weapon:LastShootTime() to get the last time the user shot for lerping

Can you tell how to even form this as a function cause Im a literal sped that cant even do a simple function.


SWEP.AddedFOV = 0
function SWEP:TranslateFOV(fov)
    return fov + SWEP.AddedFOV
end

then you can change SWEP.AddedFOV from primaryattack or something

I much prefer the method implied by code_gs:
[lua]function SWEP:TranslateFOV(fov)
return fov + math.max(3 * (0.5 - self:LastShootTime()), 0)
end[/lua]
0.5 is the amount of time in seconds that the effect is visible after firing, 3 is a multiplier for the magnitude of the effect. Untested of course.

sadly doesn’t work

Where did you put it? And does your SWEP call FireBullets?

Yep

Oh, I see the problem.


function SWEP:TranslateFOV(fov)
	return fov + math.max(3 * (CurTime() + 0.5 - self:LastShootTime()), 0)
end

lol it works but broken
My view model became upside down lol
thats a low fov

You can adjust the scaling yourself, and it’s a known bug for the viewmodel to turn upside down at low FOVs.

the thing is it nonstop changes fov without even shooting