Unity3D Photon: Wait for all buffered RPCs to be called.

edited June 2015 in DotNet
Hi, I am having a lot of fun with the Photon Network asset, and I'm having this issue where I need to instantiate the players at different spawn spots, but not in a random way, instead I thought it would work to have a index variable and after each instantiation call a RPC function to increase that variable and use
PhotonTargets.AllBuffered()
to call it for any players joining after.

The issue though, is that I instantiate the player in the
Photon.OnJoinedRoom()
function which is most definitely called before the RPC function to increase the variable I spoke about earlier. So I need a way to make sure the buffered RPCs has already been called before instantiating the player.

Thanks in advance folks! :D

Comments

  • vadimvadim ✭✭✭
    Hi,
    Store index variable in room custom properties. Increment it on master client and send 'spawn' RPC to new joined client. This would make things clearer and help to avoid concurrency issues.
  • Thank you, how can I store the variable in the room custom properties? I haven't used it before. And I'm not sure how I can detect a new player that joins and send an RPC to that player.
  • Use Room.SetCustomProperties.
    The room is available as PhotonNetwork.room.
    All callbacks are listed in enum PhotonNetworkingMessage (each value refers to one callback and explains how it must be implemented).

    I hope that helps.
  • Hello, I have a similar question.

    I would wish to be notified when Network.Instantiate()'s or some other buffered RPC's are executed on newly-connected clients.
    Do I have to handle this on the game side by null checking etc, or does Photon give me a handle with that?

    From what I understand, clients don't have any way to peek at about-to-be-executed RPC's or something like that, because there isn't really any "buffer". Buffered RPC's are executed in the same way with "live" ones, when PhotonPeer.DispatchIncomingCommands() is called. Am I correct?

    Thanks in advance.
  • I think you are correct. If you mean what I understood :)
    There is no flag which messages were buffered and which ones are "live", so there is no way to detect when everything should be setup and where live gameplay starts.
    How do you plan to use it?
  • My plan was to set instantiated objects' some properties which are read from file or fetched via WWW. I wanted to make sure objects are instantiated (on the client) before those set calls, since time spent on getting the data ready may vary significantly.
    What I do is halting the execution with straightforward null checks, but I think I could store those data within room properties, like you said. I'll give that a shot, if things start to get out of hand.

    Thank you for your answer.
Sign In or Register to comment.