Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Why does NetworkTransformChild have to be attached on the root object?

Discussion in 'Multiplayer' started by Ladace, Nov 23, 2017.

  1. Ladace

    Ladace

    Joined:
    Dec 7, 2014
    Posts:
    40
    When I was using UNET I had a question. There're no such constraints for NetworkTransform that requires the GameObject should be a root in the hierarchy. But as long as I attached a NetworkTransformChild, I could no longer put this GameObject under others.

    This doesn't look reasonable to me, and it actually has already affected the development of my project. So I wonder why. Is it possible to remove this strange constraint?
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    All the networking starts at NetworkIdentity - so all NetworkBehaviours have to be a component next to it (aka not on children)
     
  3. Ladace

    Ladace

    Joined:
    Dec 7, 2014
    Posts:
    40
    Right. But there's not such requirement that GameObjects with NetworkIdentity should be root GameObjects. So why does NetworkTransformChild have to be on root GameObjects?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    My understanding is the NetworkIdentity in fact does need to be on the root GameObject.

    https://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.html

    And the NetworkTransformChild needs to be on the same GameObject as the NetworkIdentity, so that's why it also has to be on the root GameObject.
     
  5. Ladace

    Ladace

    Joined:
    Dec 7, 2014
    Posts:
    40
    Oh I see. Wasn't aware of that. Thanks!

    I was putting GameObjects with NetworkIdentity under other objects when they are spawned, and it seemed fine.

    Hmm this constraint makes it harder to group GameObjects in the hierarchy.