Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to spawn a prefab with NetworkBehavior children?

Discussion in 'Multiplayer' started by DrWypeout, Oct 6, 2015.

  1. DrWypeout

    DrWypeout

    Joined:
    Apr 23, 2015
    Posts:
    2
    I have a complex prefab which has a NetworkBehavior, and it has several children with NetworkBehaviors. When I spawn the prefab, it spawns on the clients correctly, but the child objects are not spawned properly. They are instantiated on the clients, but they are not updated. If I try to spawn the child elements on the server, I get multiple copies of the parent prefab on clients, and the children are still not updated properly. Is this a bug, or is this intentional, and if it is, what is the recommended workaround?
     
  2. Darhkuan

    Darhkuan

    Joined:
    Feb 24, 2014
    Posts:
    21
    DrWypeout this might not relate but there is a limitation with nested prefabs and not holding all the lower level data properly. Might be worth having a look at that?

    Also having multiple layers of networkBehaviours may not work either, because as per documentation:
    http://docs.unity3d.com/Manual/class-NetworkBehaviour.html
    An object that has a networkbehaviour attached to it must be spawned directly, so when you spawn the parent, it wont spawn the children objects if I understand correctly.
     
  3. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    this is not supported.