m_angEyeAngles[0] errors

**


DataTable warning: player: Out-of-range value (351.650513) in SendPropFloat 'm_angEyeAngles[0]', clamping.

**
While (in my 2D GM) i turn left, it gives that error.
May it be this?
[lua]function GM:CreateMove( cmd )
local Pl = LocalPlayer()
local MousePosition = gui.ScreenToVector(gui.MousePos())
local MousePositionx, MousePositiony = gui.MousePos()

	cmd:SetForwardMove( cmd:GetSideMove() )
	
	local shootingpos = ( Pl:GetShootPos() ):ToScreen()
	--if ydiff <= 0 then
	local ang = math.Rad2Deg( math.atan2( (MousePositiony - 10) - shootingpos.y, (MousePositionx - 10) - shootingpos.x ) )
	--end
	
	if MousePosition.y <= 0 then
		cmd:SetViewAngles( Angle( ang, -90, 0 ) )
	else
		cmd:SetViewAngles( Angle( 180 - ang, 90, 0 ) )
		cmd:SetForwardMove( -cmd:GetSideMove() )
	end
	
	cmd:SetSideMove( 0 )
	
end	[/lua]

Just incase you’re wrong: Normalise your angles before setting them.


attempt to index local 'ang' (a number value)

Doing “ang” normalized.

ang.p = math.NormalizeAngle(ang.p)

And so on for y , r

But ang is just a number, it hasn’t got yaw, roll and pitch.

Its the map possibly

Edit
There are reports of it from tf2 so an engine bug?

No no, I meant normalise each individual part of your angle before you set it.

Instead of ucmd:SetViewAngles(ang) do

ang.p , ang.y , ang.r = – normalise p , y , r
ucmd:SetViewAngles(ang)

Just saw you posted the code. I’ll show you why it shows engine errors.

[editline]12:34AM[/editline]

[lua]function GM:CreateMove( cmd )
local Pl = LocalPlayer()
local MousePosition = gui.ScreenToVector(gui.MousePos())
local MousePositionx, MousePositiony = gui.MousePos()

cmd:SetForwardMove( cmd:GetSideMove() )
	
local shootingpos = ( Pl:GetShootPos() ):ToScreen()
--if ydiff <= 0 then
local ang = math.Rad2Deg( math.atan2( (MousePositiony - 10) - shootingpos.y, (MousePositionx - 10) - shootingpos.x ) )
ang = math.NormalizeAngle(ang) -- ang is 359 or something, instead it needs to be 179
--end
	
if MousePosition.y <= 0 then
	cmd:SetViewAngles( Angle( ang, -90, 0 ) )
else
	cmd:SetViewAngles( Angle( 180 - ang, 90, 0 ) )
	cmd:SetForwardMove( -cmd:GetSideMove() )
end
	
cmd:SetSideMove( 0 )

end [/lua]

I still don’t get why are you normalizing the pitch, yaw and roll of one angle…
As shown in the code ang is just a number not a whole angle.

See his edit, he’s normalizing ang.

I already tried what’s in his edit and it didn’t work(same bug).

Change line 17 to
[lua]cmd:SetViewAngles( Angle( math.NormalizeAngle( 180 - ang ), 90, 0 ) )[/lua]
Since normalized angle is between -179 to 180. 180 - (-171) would be 351, like in your error.

Thanks a thousand! That’s perfect :holy: