- Home /
Sending (and receiving) player names with Photon Networking
I'm using Photon Networking to make a multiplayer server game. My question is, when I instantiate a player, I want to set a string on a script on that prefab spawned (which is on all other networks too) to whatever that player's name is. I'm pretty sure the place I'm looking to do this is when I instantiate it using PhotonNetworking's instantiation command:
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
So this will spawn that prefab on all other people's connection too. My question is, is there a way to also send the player's name they enter when they start (PhotonNetwork.player.name) to all other connections too? I'm thinking after the 0 I can insert an 'object[] data' parameter, but I don't know how I could make that PhotonNetwork.player.name even if I set a string to it. Any ideas? Should I find some ways using RPCs? Because if I use RPCs, how am I going to find that player again after I spawn it? Thanks