Instantiate players in different rooms

Hi mates I am trying to instantiate prefabs in different rooms first prefab will be in first room and second prefab will be in second room and finally third prefab will be in first room again it is continuing like this. I created a lobby and added a start button which run this lines.
public void OnStartGameButtonClicked()
    {
        if(PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.LoadLevel("GameScene");
        }
    }

For instantiating I added a GameManager.cs to my level scene in a empty gameobject and I added these lines
void Start()
    {
        if (PhotonNetwork.IsConnectedAndReady)
        {
            if (_playerPrefab != null)
            {
                if (PhotonNetwork.CurrentRoom.PlayerCount % 2 == 0)
                {
                    PhotonNetwork.Instantiate(_playerPrefab.name, _spawnPoints[0].transform.position, Quaternion.identity);
                }
                else
                {
                    PhotonNetwork.Instantiate(_playerPrefab.name, _spawnPoints[1].transform.position, Quaternion.identity);
                }
            }
        }
    }

But unfortunately its spawning them in a same position. Do you know what should I do for solve this problem? Thanks and have a great day!!:D
Sign In or Register to comment.