Search Unity

Reset Counter on OnJoinedRoom help

Discussion in 'Multiplayer' started by SteamGear, Apr 19, 2014.

  1. SteamGear

    SteamGear

    Joined:
    Apr 18, 2014
    Posts:
    5
    Hello, i have 2 coutners which show the score of both players, if a new player joins i want to reset the score for both players (reset the "new player" score is easy) but the player that already is connected keeps the scores up, how can i reset the scores on both sides if a new player joins?
    Code (csharp):
    1. public class Score: MonoBehaviour {
    2.     public int score;
    3.     void Update() {
    4.          
    5.        
    6.         GetComponent<TextMesh>().text= score.ToString();
    7.  
    8. }
    9.     void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    10.     {
    11.         if(stream.isWriting)
    12.         {
    13.             stream.SendNext(score);
    14.  
    15.         }
    16.         else
    17.         {
    18.             score=(int) stream.ReceiveNext();
    19.  
    20.         }
    21. }
    22. }
    thats my current code, but it doesnt affect the players which were in the room when the new player joined