Search Unity

Multiple Network Identities on one prefab

Discussion in 'Multiplayer' started by martaaay, Jun 21, 2017.

  1. martaaay

    martaaay

    Joined:
    Apr 13, 2009
    Posts:
    136
    I'm getting this message:
    "Prefab 'Platform' has several NetworkIdentity components attached to itself or its children, this is not supported."

    Even though I'm not spawning in this prefab (it's already in the scene). I even get this message if I detach the prefab from the instantiated object. (This is one prefab with lots of pieces each with it's own Network Identity). Do I basically need to just bring in each piece separately?

    I'm using Unity 5.6.1f1.
     
  2. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    244
    Unet doesn't like nesting network identity scripts.

    You should try to come up with a way of structuring your setup so that there's only one network identity on the entire object.
     
  3. Deleted User

    Deleted User

    Guest

    Just use 1 network identity component on the root of the prefab.Btw, what are you trying to make? Maybe I can help you with finding a solution.

    -Speedex
     
  4. stjernerlever

    stjernerlever

    Joined:
    Oct 25, 2015
    Posts:
    10
    I have the same problem. In my case, I have a prefab for an apple tree. The apples are items that can be picked up, and the tree has health and can be cut down. Therefore I'm thinking all of the objects need to have an identity, as they are functioning individually.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    NetworkIdentity components are only supported on the root gameobject, not child objects.
     
  6. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    No, just the tree, but since it has Health, then you already have a NetworkBehavior on it too. Just extend that with an array of game objects and add your apples to that array. When the apple is picked, remove it from the array and sync the array to clients.