Search Unity

Third Party Photon RPC Functions Not Responding As Expected

Discussion in 'Multiplayer' started by lycanrising, Feb 22, 2015.

  1. lycanrising

    lycanrising

    Joined:
    Jan 25, 2015
    Posts:
    3
    Hi, I'm having an issue that's I have been unable to solve over maybe 10 days of work.

    I'm using Photon for Unity and I'm trying to implement a 'ready' system. Here is the code for how I'm trying to work it:

    Code (CSharp):
    1. //On a non-networked GameObject
    2. public void onUIClick()
    3.     {
    4. //me is the player's GameObject
    5.         me.GetComponent<PhotonView>().RPC("readyUp", PhotonTargets.AllBuffered);
    6.     }
    7.  
    8. //On the networked player GameObject
    9. [RPC]
    10.     public void readyUp()
    11.     {
    12.             readyNumber += 1;
    13.             Debug.Log(readyNumber);
    14. //If the number of people who have clicked 'ready' is the same as the number of people in the room
    15.         if (readyNumber == PhotonNetwork.playerList.Length)
    16.         {
    17. //going begins the game
    18.             going();
    19.         }
    20.     }
    What I feel should be happening is that when a player clicks the button, all players increment their 'readyNumber' integer. However what is actually happening is that only the client who clicked 'ready' increments to integer.

    Could anyone share some advice on this matter?
     
  2. KarlGG

    KarlGG

    Joined:
    Nov 4, 2014
    Posts:
    34
    Are you sitting in a lobby during that? Or have you already joined a room?
     
  3. lycanrising

    lycanrising

    Joined:
    Jan 25, 2015
    Posts:
    3
    Already in a room.
     
  4. KarlGG

    KarlGG

    Joined:
    Nov 4, 2014
    Posts:
    34
    I am assuming that is running in some sort of "manager" script, and the object "me" is somewhere else. Maybe that's encapsulating each player's count to themselves.

    Try using the manager's PhotonView instead of the player object.