Search Unity

Network Transform updating motionless objects on network

Discussion in 'Multiplayer' started by Doghelmer, Dec 12, 2016.

  1. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I posted this problem within another thread, but I thought that maybe it deserved its own topic, since I can't seem to find anything else on the issue.

    Sometimes, an object's NetworkTransform sends out Syncvars even when the object is completely motionless. But only sometimes. I can't find any rhyme or reason to this -- In one instance, I managed to create two objects in the scene that are entirely the same in every way in the inspector, yet one of them is causing the profiler's syncvar count to increase while the other is not (as indicated by enabling and disabling the two objects). In one instance, the issue stopped occurring when I used "Sync Transform" instead of "Sync Rigidbody 2D". Yet, I found another instance where the issue occurred with an object using Sync Transform. The issue stops occurring if I set the movement threshold to a much higher amount.

    If anyone's dealt with this before, I'd love to know what the underlying cause might be or how to fix it.
     
  2. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    Figured out the cause by delving into the Network Transform source. When it compares the current position with the previous position, it uses transform.position for the current position, and m_RigidBody2D.position for the previous position. The problem is that m_RigidBody2D.position always has a z of 0, while transform.position doesn't necessarily. So it always thinks that there has been a change in position.