Hi, I'm trying to Sync the number of players of my game, so I can set them into a position and so one. I use RPC calls to control it better and be more efficient.
Here's how's the inspector of the game maganer:
![]()
On the NetworkPlayersManager I have this code for RPC calls:
public int numPlayer;
[PunRPC]
public void GetPlayers()
{
GetComponent().setNumOfPlayers(numPlayer);
}
[PunRPC]
public void SetPlayers(int num)
{
numPlayer = num;
}
And then I call them on the GameManager code like this:
GetComponent().RPC("GetPlayers", PhotonTargets.AllBuffered);
m_Tanks.m_Instance =
PhotonNetwork.Instantiate("Tank", m_Spawns[numOfPlayers].position, m_Spawns[numOfPlayers].rotation,0) as GameObject;
numOfPlayers += 1;
m_Tanks.m_PlayerNumber = numOfPlayers;
GetComponent().RPC("SetPlayers", PhotonTargets.AllBuffered, numOfPlayers);
The number of players always is 1. It's like the info doesn't sync and every new instance of the player starts at 0 and identifies them as player 1.
Here's how's the inspector of the game maganer:

On the NetworkPlayersManager I have this code for RPC calls:
public int numPlayer;
[PunRPC]
public void GetPlayers()
{
GetComponent().setNumOfPlayers(numPlayer);
}
[PunRPC]
public void SetPlayers(int num)
{
numPlayer = num;
}
And then I call them on the GameManager code like this:
GetComponent().RPC("GetPlayers", PhotonTargets.AllBuffered);
m_Tanks.m_Instance =
PhotonNetwork.Instantiate("Tank", m_Spawns[numOfPlayers].position, m_Spawns[numOfPlayers].rotation,0) as GameObject;
numOfPlayers += 1;
m_Tanks.m_PlayerNumber = numOfPlayers;
GetComponent().RPC("SetPlayers", PhotonTargets.AllBuffered, numOfPlayers);
The number of players always is 1. It's like the info doesn't sync and every new instance of the player starts at 0 and identifies them as player 1.