Basic question about master client

Options
Im making a game like a moba/tower defense.
So the queston is: If the master leave the match what will happen? Somebody else get the master automatically?(because i dont want the match to end just because 1 ppl left, i use some RPC and other stuffs that need one master)
If not, how can i do that?
The only way i found was to the master use PhotonNetwork.SetMasterClient, but its not really a good option for my problem.

Comments

  • N1warhead
    Options
    As far as I know of it is done automatically (I don't work for Exitgames).
    But from my experience when Photon it should be done automatically if the Master leaves, it should automatically go to another person.

    I could be wrong though, but hopefully what I said is correct.

    Hope that helps buddy!
  • Thanks man, but i have one more question, how can i instantiate monsters and they dont belong to anybody?
    I mean, they belong to the scene not to any client.
    Im asking that because every X seconds, one monster is going to be instantiate, but he dont belong to anyone.
    At this moment im using the master client to use PhotonNetwork.Instantiate, and they are sync fine with the other clients, but if the master leaves, all monsters are leaving with him, and its not cool :/
  • N1warhead
    Options
    You could try setting up Spawn point around your map and having them instantiate through the game instead of by a master.

    Like set up 3 random spawn points, and have in the

    void Start(){
    PhotonNetwork.Instantiate, the rest off your code.
    }

    That way you have the game do it instead of the host.
    But again I may be wrong LOL.

    I believe there is a command to search for the new master as well, but I don't remember off the top of my head.
    if that don't work, try and see if a DontDestroyOnLoad works.
  • N1warhead wrote:
    You could try setting up Spawn point around your map and having them instantiate through the game instead of by a master.

    Like set up 3 random spawn points, and have in the

    void Start(){
    PhotonNetwork.Instantiate, the rest off your code.
    }

    This way don work, if i have a spawn point and every client run this code its gonna spawn more than 1 monster at time.
    I mean, if the game has 2 ppl, one master and 1 client, and each one has this script running its gonna spawn 2 monters (1 from the master and another from the client) at time.
    So im only using this script on the master, so i wont have this problem, but this way i have the problem i mentioned early.
  • vadim
    Options
    Hi,

    Call PhotonNetwork.InstantiateSceneObject on master client to spawn monsters. They are controlled by master client but not get destroyed when it leaves and switch their ownership to new master client.
  • vadim wrote:
    Hi,

    Call PhotonNetwork.InstantiateSceneObject on master client to spawn monsters. They are controlled by master client but not get destroyed when it leaves and switch their ownership to new master client.

    thanks man, it worked :D