problem with dontdestroyonload login information
Options
ok, ive had this problem bugging me for the last 2 days. i have a login system that, once logged in, creates a dontdestroyonload gameobject that stores the players stats e.g. Username, kills, deaths, etc. when a player joins a room he connects to this object and gets his name, to be used on the scoreboard and nametag. but when the second player joins, he doesnt get his name. his name is just blank. can someone help? ive asked everywhere
0
Best Answer
-
Hi @LeytonMate,
the reason most likely is, that these information are not synchronized across the network. Instead of using a further object, you can basically use the options PUN provides.
Username: this can be set by usingPhotonNetwork.player.NickName
. Once set it will be synchronized across all clients in the same room.
Kills and deaths: there is a scoring system included in PUN which uses the Custom Player Properties. So for setting kills, you can for example usePhotonNetwork.player.SetScore(int score);
orPhotonNetwork.player.AddScore(int scoreToAdd);
. This one gets synchronizied automatically as well. For counting deaths, you could probably build a similar system which is using the Custom Player Properties, too.5
Answers
-
Hi @LeytonMate,
the reason most likely is, that these information are not synchronized across the network. Instead of using a further object, you can basically use the options PUN provides.
Username: this can be set by usingPhotonNetwork.player.NickName
. Once set it will be synchronized across all clients in the same room.
Kills and deaths: there is a scoring system included in PUN which uses the Custom Player Properties. So for setting kills, you can for example usePhotonNetwork.player.SetScore(int score);
orPhotonNetwork.player.AddScore(int scoreToAdd);
. This one gets synchronizied automatically as well. For counting deaths, you could probably build a similar system which is using the Custom Player Properties, too.5 -
I did some digging, found people with the same problem, an took the solution from there. I dont know why i didnt use photons username system earlier lol0