Scene PhotonView RPCs not working after re joining the game

I can not handle rpcs very well by leaving and joining again, I'll describe the situation:

I have a scene photon view attached to a game object named "LevelManager". It manages some bonus items in the game by distributing them randomly.

1 - Player one creates a game and loads level 1. LevelManager creates the bonus items randomly and that's good.
it's doing it with an index array and calling PhotonTargets.AllBuffered RPCs from it's attached scene photonview.

2 - Player two joins the same game and loads level 1. LevelManager creates the same bonus items. All perfect.

3 - Now player one (masterplayer) leaves with this code :

Now he joins again the same game but now none of RPCs that LevelManager produced work. The bonus objects wont be created.

I used this code for loading the level after calling
For joining the game and loading level I used this part of code:
//on button click
void OnJoinedRoom()
PhotonNetwork.isMessageQueueRunning = false;
void OnLevelWasLoaded(int levelIndex)
{ PhotonNetwork.isMessageQueueRunning = true;}[/code2]

And I like to add while loading a level cpu usage is very high and for a second or tow the game freeze up!
I hope the situation be enough clear to get some good ideas on my problem.

thank you


  • Tobias
    Oh, right. That topic was still open.

    By default, we clean up the events of a player when said player leaves the room. This can be turned off but that means more effort on your side.

    There is one option to cache events you send as "belonging to the room". In that case, these events are not removed.
    This is what we use to instantiate scene game objects while the room is active.
    However: There is no option yet to make RPCs belonging to the scene, which is why a players RPCs are lost when he leaves.
    You could edit it in.
    Add a new value to enum PhotonTargets. E.g. "bufferedinroom". In NetworkingPeer.RPC() you handle this new value by calling OpRaiseEvent(..., EventCaching.AddToRoomCacheGlobal, ...) and the event belongs to the room.
    Careful: Depending on how long the room lives (any player still in it), this can amass a lot of events which are sent on join! This can easily lead to other issues and only makes sense for few events.

    Unless you turned off the auto cleanup of events for a room, you don't have to remove them manually from the cache. Simply call LeaveRoom() but not the Remove* methods.
  • I ran into a similar problem, with RPC events not being delivered when a player calls LeaveRoom().

    I tried disabling the autocleanup as described, putting this line before any room creation:

    PhotonNetwork.autoCleanUpPlayerObjects = false;

    But the RPC's still don't get delivered. The RPC call gets made, but never shows up in other players games. I commented out the LeaveRoom() to confirm the call is functioning, then it works fine. Am I missing something else?
  • Tobias
    When you call leave() before your RPCs left your client, then they won't be sent. Instead, your client disconnects directly.
    You could call PhotonNetwork.SendOutgoingCommands() before you call leave. This way, everything queued is sent before you leave.