After two weeks of PUN, these are my questions...

Options
So I have a game lobby, room connect, all the seemingly easy stuff done. Running into a lot of bugs and knowledge gaps though. I'll just ask all my questions here in hopes that a few get answered...

1. Is it quicker to have fewer PhotonView components? Should I just have one PhotonView per player, and one for all the AI? That would be more difficult, but if it's worth it, I would like to implement that in the early stages of development

2. Do you need a PhotonView component on every component that HAS a script with an [RPC], every component that has a script that CALLS an [RPC], or both?

3. Would it be more efficient to have an [RPC] call to change animations, or change and send all the animator Bools in an OnPhotonSerializeView if my players have upwards of 50 animation bools?

4. Can you do programming logic in an OnPhotonSerializeView to ensure that variables get updates before certain events? If not, is there function that I'm missing that waits for an update before firing?

5. Using Photon.Instantiate, is there any way to load previously Instantiated objects on join, or a built in way to make sure all players are in connected and loaded the scene? What's happening right now, the first player that joins loads the second, but that second player that joins only loads himself and doesn't load the previously instantiated Players.

6. How does inheritance work as far as RPCs go? I've ran into some problems with this.

I know that was a lot, but I've spent the last 20 hours effectively doing nothing, and none of my research has offered any useful answers. Maybe I'm just bad at research...

Thanks to anyone who tries to lend a hand!

Comments

  • Also, PhotonNetwork.LoadLevel called by my master client doesn't always sync up.

    I have put PhotonNetwork.automaticallySyncScene = true; as the first thing in my OnJoinedGame function which appears to be firing properly. Right now it's on all clients, should it only be on the master client?
  • Tobias
    Options
    1. I can't say because I don't know the alternative well. It should not make up most of your CPU time in either case.
    This is related: http://doc.exitgames.com/en/pun/current/tutorials/synchronization-and-state

    2. RPCs are executed by all clients for the GO on which you called it initially. They relate to a GO and that needs the PhotonView. You can of course have your own IDs for objects and call all RPCs on the same. That's sometimes a good solution. If you want to send messages independent of GOs, use RaiseEvent.

    3. Please experiment. Can't really say reliably.

    4. Reliable updates are always in sequence and the sequence is complete. If something is missing and an event should wait, this is due to the game logic. You can use game logic in OnPhotonSerializeView but you can't block that execution thread.

    5. Instantiates are done early when you join a room. Only the properties of the room are available before that. You could use that to load the fitting scene when you join and get the props. This is done by PhotonNetwork.LoadLevel(), too.
    I hope the last paragraph helps "Timing for RPCs and Loading Levels":
    http://doc.exitgames.com/en/pun/current/getting-started/feature-overview

    6. Some problems is too vague to help. Please experiment and let me know if you have a feature request or a bug.

    7. You need to set PhotonNetwork.automaticallySyncScene before you join any rooms. In best case, simply do that before you connect (in all clients alike).