Search Unity

PhotonNetwork.InstantiateSceneObject works in editor but not in build

Discussion in 'Scripting' started by Narfi01, Jan 17, 2014.

  1. Narfi01

    Narfi01

    Joined:
    Dec 18, 2013
    Posts:
    6
    Code (csharp):
    1. if ((numberThatHaveSpawned < numberToSpawn)  (spawnToggleOnOff == 1)  PhotonNetwork.isMasterClient) {
    2.                         PhotonNetwork.InstantiateSceneObject (whatToSpawn1.name, spawnPoint, Quaternion.identity, 0, null);
    3.                         numberThatHaveSpawned ++;
    4.  
    5.                 }
    This runs just fine in the editor, and will spawn however many creatures I specify.
    However if I build the project and start the exe, then it does not.
    I have tested starting a built game, connecting with the editor, then connecting with another built game.

    Since the first game started is the master client and is not the editor nothing is spawned, but if i exit out of that game and the editor (as the second to connect) becomes the master client then they are spawned and visible on both the editor and the 3rd game connected.

    Obviously I don't want to have the editor be required to run as the master client, so how do I get things to instantiate properly in the built games?

    Yes, the prefabs are in a Resources folder.
     
  2. Narfi01

    Narfi01

    Joined:
    Dec 18, 2013
    Posts:
    6
    Anyone?
     
  3. Narfi01

    Narfi01

    Joined:
    Dec 18, 2013
    Posts:
    6
    Figured it out...
    I had started with a Jscript and the converted it into C#, having the two scripts with the same name in the project even though only one was being used caused the issue, deleting the Jscript fixed the issues.
     
  4. Brachiosaurus

    Brachiosaurus

    Joined:
    Jul 2, 2016
    Posts:
    1
    Hi there, @Narfi01 I am having the same exact issue except I didn't have a Jscript to delete. Do you have any hints for me? I really need help