Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Problem with Photon

Discussion in 'Multiplayer' started by fred_gds, Jan 21, 2015.

  1. fred_gds

    fred_gds

    Joined:
    Sep 20, 2012
    Posts:
    184
    Hey,

    I started using Photon and today I ran in a quite strange Error/Bug.

    So I created a room and I have 2 players in it. So then I load a new Scene through the master with PhotonNetwork.LoadLevel(). Everything works great until here. But then I wanted the master instantiate further GameObjects. Therefore I wrote following script:

    void Awake()
    {
    if(PhotonNetwork.isMasterClient)
    {
    PhotonNetwork.Instantiate("Player123" , Vector3.zero, Quaternion.identity, 0);
    }
    }

    strangely the objects only appear on the master but not on the clients.

    But if I use if(!PhotonNetwork.isMasterClient) instead then the Objects will be spawned on the clients and the master. So I don't quite understand logic behind that and after spending hours to try figure out how it is supposed to work, I wanted to ask if anyone else ran into similar problems.

    By the way the Objects I want to Instantiate are static and have a PhotonView Component attached to them.


    EDIT: I found the problem. Apparently the Awake function of the master gets loaded before the other player join. So therefore the Instantiation will not work inside Awake()....
     
    Last edited: Jan 21, 2015