Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Using NetworkManager player prefab with a parent and child

Discussion in 'Connected Games' started by _Kyle, Aug 10, 2018 at 7:11 AM.

  1. _Kyle

    _Kyle

    Joined:
    Jul 30, 2018
    Posts:
    3
    I've got a parent and child object that I'm wanting as the player prefab. I need the parent to stay still and the child to move around the scene. I've got it to work when it's not attached to unitys network manager but when I set it as the prefab it doesn't work.

    Also, when I set just the child as it's own object in the prefab it works as well. The problem seems to be when I make it a child. Why might this be?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    2,996
    I'm guessing you're running into issues of multiple NetworkIdentity components on a single prefab. Unet doesn't support NetworkIdentity components on child objects, only on the root object of the prefab. Unet doesn't support NetworkBehaviour components or built in network related components such as NetworkTransform on objects that do not have a NetworkIdentity component, so these also need to be on the root object of the prefab.

    You could use NetworkTransformChild on the parent object to reference the child object you want to move around and sync its position to clients, but NetworkTransformChild is pretty simplistic.

    https://docs.unity3d.com/Manual/class-NetworkTransformChild.html

    My recommendation would be to make these two entirely separate prefabs and instantiate/spawn the second prefab on the server after the first prefab is spawned and just get a reference to this second object on the first object.