Invalid parameter because it was infinity or nan

We are currently working on a multiplayer game and we have a bug that we are having a really hard time resolving. The error that we get is:

Invalid parameter because it was infinity or nan.
UnityEngine.Transform:INTERNAL_set_rotation(Quaternion)
UnityEngine.Transform:set_rotation(Quaternion)
NetworkTransformSync:Update()

[C:/BuildAgent/work/842f9557127e852/Runtime/Dynamics/Collider.cpp line 150]
(Filename: C:/BuildAgent/work/842f9557127e852/Runtime/Dynamics/Collider.cpp Line: 150)

When this happens our log is filled with this message and our frame rate tanks to 5-6 fps. This problem does not seem to show up until we around 10+ people into our game, with 5-7 players we never see this issue. We have been trying to determine the source of the problem for a while now, however we have not been successful. Our code within NetworkTransformSync::Update() where we set the rotation looks like:

Quaternion newRotation = data.rotation;
newRotation = QuaternionMath.Normalize( newRotation );
if (float.IsInfinity( newRotation.x ) || float.IsNaN( newRotation.x ) ||
    float.IsInfinity( newRotation.y ) || float.IsNaN( newRotation.y ) ||
    float.IsInfinity( newRotation.z ) || float.IsNaN( newRotation.z ) ||
    float.IsInfinity( newRotation.w ) || float.IsNaN( newRotation.w ))
{
	Debug.LogError( "ERROR: transformRecvQueue.Count > 0 -> newRotation is bad" );
	newRotation = Quaternion.identity;
}
transform.rotation = newRotation;

We check for both Infinity and NaN before we set the values and correct if necessary however this does not seem to help. I was hoping that someone from unity could share what is going on within Collider.cpp line 150 so that we could better understand what the problem is.

We are at a loss and could really use some help,

  • Peter

Did you figure this out? I’m having the same bug.