Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Resolved Skipping updating the transform of this Rigidbody

Discussion in 'Netcode for GameObjects' started by CosmoM, Feb 4, 2022.

  1. CosmoM


    Oct 31, 2015
    My players can spawn networked items (through ServerRpc) that have rigidbodies and start falling as soon as they are spawned, with a little animation. They have a NetworkObject, NetworkTransform, and NetworkAnimator (but no NetworkRigidbody, since I set the rigidbodies to kinematic for all clients – though I tried and adding a NetworkRigidbody changes nothing). When the host does this, it works perfectly on all clients. When a client does this, it sometimes works perfectly, but most times all of the following happens:

    - The item is spawned for everyone
    - The animation plays on the server, but not on the clients
    - The item hangs at its spawned position for everyone, and the server constantly produces the error "Skipped updating the transform of this Rigidbody because its components are infinite"

    However, I checked, and they are not. The positions and velocities of the rigidbodies are perfectly normal and as intended, so is the inertia tensor. The rigidbody is initialized with a force at initialization (VelocityChange) and at no point thereafter (though gravity is on). Logging the velocity shows that it is unchanged even after the error, it doesn't suddenly become infinite or NaN, it is completely constant from the moment it's initialized.

    The relevant code on the items:

    Code (CSharp):
    1.     public override void OnNetworkSpawn() {
    2.         if (!IsServer) {
    3.             myRigid.isKinematic=true;
    4.             myRigid.useGravity=false;
    5.         } //if
    6.         else {
    7.             //Activate fall animation
    8.             myAnim.SetTrigger(animFalling);
    9.             myRigid.AddForce(startVel,ForceMode.VelocityChange);
    10.             myTransform.localScale=new Vector3(0.1f,0.1f,0.1f);
    11.             wasInitialized=true;
    12.         } //else
    13.     } //OnNetworkSpawn
    I'm at a total loss as to why this is happening. The only hint I have is that the problem goes away if I completely disable the colliders on the object, though I checked and the item does not collide when they are on (i.e. OnColliderEnter/Stay/Exit do not fire when the colliders are on). Does anyone have any idea?
    Last edited: Feb 4, 2022
  2. CosmoM


    Oct 31, 2015
    Finally solved it. The problem was that Update() was being called on the same frame as OnNetworkSpawn(), which led to the transform.localScale being set to 0 for one frame.