Character selection in multiplayer game?

Hi,

I’m trying to figure out how to select a character, store that info while I’m entering the lobby and chat in my multiplayer game, and then spawn that particular player I selected when I press the start match button.

I read that the pthoton view ID is unique to gameobjects in a game so: Can I allocate a photon view ID for each of my characters in my game, so that when a gamer selects that player, the ID can be what determines which character spawns?

How do I store the ID ?

This is my spawn code for when I press start match, and it only works for one character in the resources folder called: “PlayerController” (There is no ID info called now):
[PunRPC]
private void RPC_CreatePlayer()
{
float randomValue = Random.Range(20f, 50f);
GameObject myPlayerGO = PhotonNetwork.Instantiate(Path.Combine(“Prefabs”, “PlayerController”), Vector3.up * randomValue, Quaternion.identity, 0);
}

I also need to be able to spawn characters at random spawn points and not somewhere inbetween Random.Range(20f, 50f);

I’d really appreciate the help.

1 Like

If you want to have the viewID determine the character model then one approach you could take could be to have your player prefab have all the available models as children and make them disabled by default. Then in the PhotonInstantiate callback you can enable the particular character model based on the viewID.

Or instead of the viewID, maybe user the PhotonView.OwnerActorNr and the modulo of the number of models to decide which character model to enable.

1 Like