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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Unity Multiplayer [Solved] Script takes Network Information from NetworkIdentity on Prefab instead of it's GameObject

Discussion in 'Multiplayer' started by janw23, Aug 26, 2016.

  1. janw23

    janw23

    Joined:
    Oct 10, 2015
    Posts:
    2
    There are 2 Player objects in my scene, one is owned by Host and one by Client. They both have Script on them to print their Network Information:

    Code (CSharp):
    1. void Awake()
    2.     {
    3.         Debug.Log("*******");
    4.         Debug.Log("PlayerControllerId " + playerControllerId);
    5.         Debug.Log("isServer " + isServer);
    6.         Debug.Log("isClient " + isClient);
    7.         Debug.Log("isLocalPlayer " + isLocalPlayer);
    8.         Debug.Log("hasAuthority " + hasAuthority);
    9.         Debug.Log("transform's InstanceID " + transform.GetInstanceID());
    10.         Debug.Log("*******");
    11.     }
    This is the output from Player owned by host:
    And this is from client's Player:
    As you can see they are completely the same except InstanceID, which is proper. According to their Network Information they should be different (screenshots are from Client's side but on Server they are also the same):

    Host:


    Client:


    I found out that printed information is from Player's Prefab:


    Do you know how can I fix this problem?
     
  2. janw23

    janw23

    Joined:
    Oct 10, 2015
    Posts:
    2
    Wow, I put it in Start() function instead of Awake() and it works :)