Search Unity

Third Party Photon PUN: Using RPCs to update a boolean

Discussion in 'Multiplayer' started by USB_Connector, Jan 21, 2015.

  1. USB_Connector

    USB_Connector

    Joined:
    Jan 17, 2015
    Posts:
    1
    I'm using unity and PUN.

    I have the following script for objects. I used the tutorial to make a really simple multiplayer game (cubes moving around). Now I'm trying to make a turn based structure using the player IDs and an RPC to tell which player to go. Pressing space disables your controls (ends the turn). However, if someone else pressed space the RPC signals all players and their controls get enabled.

    I've put in debug scripts and everything does happen as it should, but the check in update() doesn't seem to change. How to I make the script realize the variable was changed?

    Code: http://pastebin.com/bT9WRMHf

    I put some more debug code in the update method, pressed space to end my turn and then pressed space on another instance of the game to make it my turn again. A few seconds later here's part of the debug log:



    So for some reason I've lost control of the photonview and when I regain it, the boolean is flipped for whatever reason. During this time there was no input.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Sorry, there is no way we can debug this. There is next to no hint what you actually do.
    What's the number at the beginning of the logs?

    You could use room.SetCustomProperties() to save who's turn it is.Check the room.customProperties hashtable on all clients to find out who's turn it is. See the documentation in your PUN package to get a description how this works.