ViewPunch question

Why does ViewPunch not work clientside?
(https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1ec1.html)

Is there an alternative?

Use the new wiki

Player:ViewPunch

It says that it’s shared. Have you tested it?

Do you have any other CalcView hook that’s overriding everything?

Did not work for me :confused:

[editline]19th May 2015[/editline]

I don’t think so :frowning:

Just tested this out, doesn’t seem to work clientside, only serverside.

Doesn’t look like there is an easy way to do it clientside. I haven’t tested this but you should be able to use

CUserCmd:SetViewAngles to change the view angles over multiple tick to smooth the effect out.

It probably be better to just network it.

So you mean I should use it serverside?

Yes

Ok, but if I use it serverside, the players feel a kind of stuttering. :confused: (It’s not smooth)
Is there no way to fix / reduce this?

CUserCmd:SetViewAngles doesn’t affect the client engines viewangles on the same tick, and depending on what place you hook may not even change them. The correct soloution for clientside viewpunch which is “smooth” ( even though imo, normal viewpunch is smooth as fuck anyways ) is CalcView.

yea, you can try using CalcView instead to easily make a clientside-based version of viewpunch.

I don’t recommend view-punch for weapon recoil because it doesn’t change point-of-impact, ie you can be view-punched to look straight up and you’ll still be hitting the exact same spot, depending on the swep setup, if you don’t move the mouse.

I use this ( example shortened to include only relevant code ) in PrimaryAttack > ShootBullet > ShootEffects:


if ( CLIENT && IsFirstTimePredicted( ) ) then
	local recoil = math.Rand( 0.5, 1.5 );
	local _eyes = self.Owner:EyeAngles( );
	_eyes.pitch = math.Clamp( _eyes.pitch - recoil, -90, 90 );
	self.Owner:SetEyeAngles( _eyes );
end

The recoil amount can be altered and you can also bump sideways or whatever but most firearms are balanced so that the recoil impulse is straight-back and down ( muzzle up ) and there are more that are so well balanced you barely have any down/up motion and others that actually make the muzzle-end go down…