How to get rid of Weapon Jitter when repositioning the View Model

I apologize if this has already been answered.

I am having issues with every weapon base where it causes your weapon to jitter or jump around if the view-model is repositioned. When a server first starts out it does not jitter but after 5-10 minutes it starts to progressively get worse and worse to a point where its just really bad. I’ve noticed it on the DarkRp base when your in passive mode and when you’re running around with the mad cows base when it holds the gun to the side. Is there a way to fix this or at least lessen the issue? If this is unfixable will it be solved in Garry’s Mod 13?


P.S. This is the code that appears to handle repositioning of the view model in darkrp as that’s the base I’m Modifying:

Name: GetViewModelPosition
Desc: Allows you to re-position the view model
function SWEP:GetViewModelPosition(pos, ang)
	if (not self.IronSightsPos) then return pos, ang end

	local bIron = self.Ironsights

	if (bIron != self.bLastIron) then
		self.bLastIron = bIron
		self.fIronTime = CurTime()

		if (bIron) then
			self.SwayScale 	= 0.3
			self.BobScale 	= 0.1
			self.SwayScale 	= 1.0
			self.BobScale 	= 1.0

	local fIronTime = self.fIronTime or 0
	if GetConVarNumber("ironshoot") ~= 0 then
		ang:RotateAroundAxis(ang:Right(), -15)
	if (not bIron and fIronTime < CurTime() - IRONSIGHT_TIME) then	
		return pos, ang

	local Mul = 1.0

	if (fIronTime > CurTime() - IRONSIGHT_TIME) then
		Mul = math.Clamp((CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1)

		if not bIron then Mul = 1 - Mul end

	local Offset	= self.IronSightsPos

	if (self.IronSightsAng) then
		ang = ang * 1
		ang:RotateAroundAxis(ang:Right(), 	self.IronSightsAng.x		* Mul)
		ang:RotateAroundAxis(ang:Up(), 		self.IronSightsAng.y * Mul)
		ang:RotateAroundAxis(ang:Forward(), 	self.IronSightsAng.z * Mul)
	if GetConVarNumber("ironshoot") ~= 0 then
		ang:RotateAroundAxis(ang:Right(), Mul * 15)
		ang:RotateAroundAxis(ang:Right(), Mul)

	local Right 	= ang:Right()
	local Up 		= ang:Up()
	local Forward 	= ang:Forward()

	pos = pos + Offset.x * Right * Mul
	pos = pos + Offset.y * Forward * Mul
	pos = pos + Offset.z * Up * Mul

	return pos, ang

I don’t see a jitter.

[editline]21st January 2012[/editline]

I’ll also try it on windows later.

It doesn’t happen immediately. IT normally happens on a multiplayer server. My friend has the issue as well. I was testing it on a multiplayer listen server and all the guns that moved the gun’s in any position in any way other than ironsight was affected by it.

It doesn’t happen on my mac and not on my windows when hosting a multiplayer server from the menu.

That’s really weird…a lot of people get the problem…Normally it happens on a listen server like 15-20 minutes into the listen server. it has to be something modifying the view model position. I’m surprised you don’t have the issue. Maybe someone else who has it knows how to fix it.

I realise this is a major bump, but has anyone ever found a solution for that?

When re-positioning the view model I set self.SwayScale to 0 to stop the jittering.

Can’t do unfortunately, we have sway animations when running…

SwayScale and BobScale are two different things.
BobScale is the weapon movement.
SwayScale is the weapon movement when you quickly look around.
You should make your own running anims instead of using the default ones.

Thank you good sir.

My players are still having this issue. It starts randomly and then doesn’t end until reloading the map. Changing SWEP.SwayScale closer and closer to zero makes the jitter softer until it disappears, but at a scale of 1 the jitter is horrid which makes SwayScale unfortunately useless to me.

Has anyone been able to work around this while preserving SwayScale?