title: Synchronizing complex GameObjects in Unity Networking - UNET
body: <p>I'm working on first person game where player can build complex objects. Structure example:</p>
  
  <pre><code>Train
  - Wagon
    - Table
    - Chair
    - Chest (stores items)
    - Workshop (manufactures items, has build queue)
  </code></pre>
  
  <p>Player is able to create <strong>trains</strong>, add <strong>wagons</strong>, place <strong>objects</strong> into <strong>wagons</strong>, modify placed <strong>objects</strong>. Whole train can move, objects are in transform hierarchy.</p>
  
  <p>Player can interact with placed objects (e.g. put items into chest, modify workshop build queue), so I need a way to identify them across network. This indicates that all objects should have <code>NetworkIdentity</code>. Some objects have also their state which needs to be synced (stored items, build queue).</p>
  
  <p>What's suggested synchronization approach? Which objects should have <code>NetworkIdentity</code>?</p>
  
  <hr>
  
  <p>Adding <code>NetworkIdentity</code> to all of them prevents me from creating Train prefabs in Editor (prefabs can have <code>NetworkIdentity</code> only on root), but I could probably live with that. I have to also "manually" set parent when wagon or object is spawned on client.</p>
  
  <hr>
  
  <p>Another solution might be to add <code>NetworkIdentity</code> only to <strong>Train</strong> and then identify objects by some ID within the <strong>train</strong>. I cannot imagine how to use <code>SyncVar</code> with this approach, since everything would have to be on the <strong>Train</strong>.</p>