vectorfrog
Member
Does anyone know of a reliable way to get the player number during, or right before spawn? I am currently using the Photon Player Numbering extensions class, and am using the custom properties to get the 'pNr', but for some reason it changes to 0 or non existent for all clients during spawn.
The reason I want this is so I can use it to spawn different characters based on the player number. I've tried using ActorNumber but that can change depending on if the player disconnects and reconnects, or rejoins the room, etc.
I have created a custom character spawn class that is basically identical to the SingleCharacterSpawnManager class. The only difference is that I have an array of prefabs for the player characters, and want to use the player number to index that array in GetCharacterPrefab.
Here is the code I am currently using to get the player number.
When the level is loaded, and GetCharacterPrefab is called, the player number is 0 for all connected clients including the master and they all use the same prefab to spawn. After the scene is loaded, the player numbers are correct (0 and 1 for a two player game), but they are already spawned at this point.
Anyone have any ideas?
The reason I want this is so I can use it to spawn different characters based on the player number. I've tried using ActorNumber but that can change depending on if the player disconnects and reconnects, or rejoins the room, etc.
I have created a custom character spawn class that is basically identical to the SingleCharacterSpawnManager class. The only difference is that I have an array of prefabs for the player characters, and want to use the player number to index that array in GetCharacterPrefab.
Here is the code I am currently using to get the player number.
C#:
if (newPlayer.CustomProperties.ContainsKey("pNr"))
{
int result = Convert.ToInt32(newPlayer.CustomProperties["pNr"]);
Debug.Log("Character ID: " + result);
return m_CharArray[result];
}
else
{
return m_CharArray[0];
}
When the level is loaded, and GetCharacterPrefab is called, the player number is 0 for all connected clients including the master and they all use the same prefab to spawn. After the scene is loaded, the player numbers are correct (0 and 1 for a two player game), but they are already spawned at this point.
Anyone have any ideas?
Last edited: