- Home /
Snychronize player's name over Photon?
This is more of a straightforward question if you understand Photon Networking. When you spawn a player using Photon Networking, that player is also spawned on other clients (with something along the lines of PhotonNetwork.Instantiate(prefab, etc);). I have set that spawning player as myPlayerGO (which is only on the local machine). What I want to do, is when I spawn that player, I also want to set a variable (which is a string) to what the local player has entered. So the local player enters a string, then they spawn across the network, while simultaneously grabbing that player and setting that one variable on ALL clients to a string on all clients. Any ideas?
Answer by Firedan1176 · May 29, 2014 at 12:50 AM
I've figured it out. I didn't need to grab a string at all, it's automatically synched with PhotonNetwork.owner
Answer by EwanKoSauHaha · May 10, 2014 at 05:23 PM
try using PhotonTargets.AllBuffered. AllBuffered RPC calls means that newly joined players will recieve the RPC calls of other players even if they have not joined yet
void addString() {
string qwe = "qwe";//player input
GetComponent().RPC ("theOtherPlayerString",PhotonTargets.AllBuffered,qwe);
}
[RPC]
void theOtherPlayerString(string m) {
Debug.Log(m);
}
Thanks, that worked! Do you have an idea how I can still grab my local player and send that string over the network? I'm still having trouble setting it over the network. I've got the RPC working you did above, but how can I set that variable?