sync variables
Options
I want all the variables for the player to be synced on all clients so the client can click on any player and see their stats. I thought this would be as simple as syncing them all when the player is first instantiated.
void Start () {
photonView.RPC("SetAll", PhotonTargets.All);
}
[PunRPC]
void SetAll () {
gameObject.name = gameObject.name;
variables = variables;
}
It doesn't work, i can click on the enemies in the inspector and none of their variables have any values. The name isn't syncedproperly either, i have a UI element that displays the name of the gameobject you've clicked. How do i sync all variables on the gameObject across all players? These same gameobjects have their transform synced properly.
void Start () {
photonView.RPC("SetAll", PhotonTargets.All);
}
[PunRPC]
void SetAll () {
gameObject.name = gameObject.name;
variables = variables;
}
It doesn't work, i can click on the enemies in the inspector and none of their variables have any values. The name isn't synced
0
Comments
-
void Start () { string tempString = "gahgsahsgfahgsh"; photonView.RPC("SetAll", PhotonTargets.All, tempString, (int)28); } [PunRPC] void SetAll (string tempString, int number) { Debug.Log(tempString + " " + number); }
Some usefull tutorials for beginners:
https://www.youtube.com/playlist?list=PLQ0PnSAYGlIb2UdVapw-yfn7-r9w7JFbk
https://www.youtube.com/playlist?list=PLbghT7MmckI7BDIGqNl_TgizCpJiXy0n91 -
Splendid, thank you. I've found it INCREDIBLY hard to get started with Photon. I've coded a lot of stuff by myself by looking up examples and tutorials. Seems like i can never find anything useful about photon. Even something incredibly simple and necessary like "how to sync variables."3
-
In any networking solution you must specify which variables should be synced and how.
There is nothing hard. Just study sample projects + read documentation, or watch tutorials on youtube.
2