sync variables
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
sync variables
NatalieBaldwin
2017-03-22 01:25:00
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 synced properly 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.
Comments
OneManArmy
2017-03-22 02:32:26
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_TgizCpJiXy0n9
NatalieBaldwin
2017-03-22 03:17:52
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."
OneManArmy
2017-03-22 11:20:37
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.