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

Question How do you sync Network Manager and Network Objects?

Discussion in 'Game Server Hosting' started by GlomyShadow, Dec 10, 2022.

  1. GlomyShadow

    GlomyShadow

    Joined:
    Jan 8, 2022
    Posts:
    4
    Essentially, on my Awake() function in the Network Object I have:

    Debug.Log($"Is server {NetworkManager.IsServer}"); //true
    Debug.Log($"Is host {NetworkManager.IsHost}"); //true
    Debug.Log($"Is client {NetworkManager.IsClient}"); //true

    Debug.Log($"Is server {IsServer}"); //false
    Debug.Log($"Is host {IsHost}"); //false
    Debug.Log($"Is client {IsClient}"); //false

    So even though the Network Manager says that I'm the host, I can't edit any of the Network Lists or Network Variables in the Network Object because the Network Object thinks that I am not the host.

    How would one fix this?
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    612
    Awake is likely too early, try using OnNetworkSpawn.
     
  3. GlomyShadow

    GlomyShadow

    Joined:
    Jan 8, 2022
    Posts:
    4
    Thanks, it now works!
     
    cerestorm likes this.