Search Unity

GameObject.Find not working with OnStartLocalPlayer for LobbyManager?

Discussion in 'Multiplayer' started by Nicolas-Liatti, Mar 2, 2016.

  1. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    Hi,

    When using the LobbyManager, if I put a GameObject.Find in the Override OnStartLocalPlayer, I get an error "Object Reference not set to an instance of an object", even if the object is in the scene. It looks like in the case of LobbyManager that OnStartLocalPlayer is called before the scene is loaded..

    If I use NetworkManager it works fine...

    Is this a bug?

    Thanks,
    Nicolas
     
  2. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    Ok I think I found the problem.

    Actually, it just does not find Object which have a Network identity component. Not sure how to deal with this....
     
  3. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    ClientScene.FindLocalObject()
    or
    NetworkServer.FindLocalObject()