Preventing Broken Ironsights - Is it possible? :V

Hey there, I’m attempting to make it so when you sprint the gun aims down but when I use GetViewModelPosition it breaks the ironsights, I’d appreciate any help!
** Edit: ** added the code.

[lua]
function SWEP:GetViewModelPosition( pos, ang )

if self.Owner:KeyDown(IN_SPEED) && self.Owner:GetVelocity():Length() > 0 && !self.Owner:KeyDown(IN_ATTACK)  then
		ang:RotateAroundAxis( ang:Forward(), -30 )
		ang:RotateAroundAxis( ang:Up(), 30)
end
		return pos, ang

end
[/lua]

What ironsights code are you using?

It’s not the ironsights that I’m coding but the ironsights are breaking whenever I use that function or CalcView. I’m trying to get a sprinting effect with the gun when they* press shift.

Don’t use CalcView - that’s to move the camera and stuff when moving, not moving the viewmodel, thats what GetViewModelPosition is for :v:

And chances are your ironsights are breaking because they use GetViewModelPosition - so when you fuck with the values in your meta function the ironsights are going to use those values, not the normal ones.

Any way to prevent this? :frowning:

You could check what values GetViewModelPosition feeds normally and force those into your ironsights code. Hacky and may not work but its all I can think of at the moment.

Am dumb, I don’t know what you mean :C

you basically use GetViewModelPosition and store them for later usage in a NWFloat.

for example , you get the X, you put it as a clientside networked float , then the same for y and z , then when you try and set them back you use those values.

Hmmk, sweet I got it to work thanks guys :stuck_out_tongue: