Room master and all start?

Options
So I've been playing around with the photon networking asset for unity, I'am now stuck in the room part where I want players to connect to a room, have a name and then the user which created the room has the option to "Start game"
When "start game" is initialized I want everyone in the (room or lobby whatever youd like to call it) to spawn out and play.

I cant seem to get this too work because everyone has the "start game" button, and they have to press it themselves.

Think of it as a COD lobby, or Counter strike global offensive lobby, one can choose when to start ( the hoster or creator of the room).

How can I achieve this?

Comments

  • vadim
    Options
    Check PhotonNetwork.isMasterClient to make ui element appear only on master client.
    Master client is the client which created the room. After this client leaves, next joined assigned as master.
  • Kingzor5
    Options
    vadim said:

    Check PhotonNetwork.isMasterClient to make ui element appear only on master client.
    Master client is the client which created the room. After this client leaves, next joined assigned as master.

    You were a bit too slow, found it late last night. Thank you though!!!!!

    Another problem, I'am now checking if the client is pressing "start game" but only he is spawning, what is wrong?.

    Here is the code.

    [PunRPC]
    public void StartGame()
    {
    if (PhotonNetwork.isMasterClient)
    {
    SpawnPlayers(0f);
    photonView.RPC("SpawnPlayers", PhotonTargets.All);

    }

    }

    void SpawnPlayers(float respawnTime)
    {
    sceneCamera.enabled = true;
    StartCoroutine("SpawnPlayer", respawnTime);
    lobbyWindow.SetActive(false);
    Spawner.SetActive(true);
    RedSpawner.SetActive(true);
    }
  • vadim
    Options
    I don't see how exactly you instantiate players.
    Make sure that SpawnPlayers is called on all clients joined to the room.
    Use logging for that. Don't forget write current client state (PhotonNetwork.connectionStateDetailed) to log and maybe players list (on master client).
  • Kingzor5
    Options
    vadim said:

    I don't see how exactly you instantiate players.
    Make sure that SpawnPlayers is called on all clients joined to the room.
    Use logging for that. Don't forget write current client state (PhotonNetwork.connectionStateDetailed) to log and maybe players list (on master client).

    Sorry for the repost, this has already been dealt with. Took some extra time but I figured it out.
  • Sidharth
    Options

    Hi kinfzor5 please can you tell me how you resolved that problem?