Search Unity

Third Party Photon Suitability

Discussion in 'Multiplayer' started by Valkrysa_Herja, May 6, 2020.

  1. Valkrysa_Herja

    Valkrysa_Herja

    Joined:
    Aug 1, 2014
    Posts:
    41
    Salutations Unity Community,
    I am sure this has been answered before somewhere so please forgive my ignorance. The games I build for my employers have only ever required networking experience with HTTP and web frameworks, never UDP and so it is a new topic for me.

    Basis:
    Although I am willing to build a solution from something low level I would prefer a package that handles as much of the grit of keeping and managing UDP connections as possible and smooth the experience; and am willing to pay costs accordingly (so free is not a requirement).
    I would prefer not to host my own server for this purpose but am willing to if need be.

    My use case:
    I want a room based system for an RTS style game, with between two and six players per room, sending a UDP message to each other once every 100 milliseconds.
    The messages would be game commands and fairly compact, to be relayed to the other players. Likely a mix of byte and string arrays.
    No actual game state would be synced between players and no gameplay integration is needed. AKA no transform syncing, prediction, etc.

    Questions:
    • Is Photon's PUN2 suitable for this use case?
    • At 2-6 players each sending 10 messages per second this should be between 40 to 360 messages per room per second. Photon advertises a 500 msgs per room per second limit but from your practical knowledge would even the 360 begin to become a problem?
    • Is it reasonable to expect that Photon's latency is low enough that one message sent per 100 milliseconds would be acceptable by their system?
    • For this use case would Photon provide any smoother of a developer experience than just writing my own solution using LiteNetLib?
    Thank you for any help you can provide and if I have failed to give some crucial piece of information please let me know.
     
    Last edited: May 6, 2020
  2. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    187
    Quite a bit of network libraries to consider in this thread here.

    https://forum.unity.com/threads/wha...of-available-network-solutions-assets.609088/

    Your use case seems ideal for Photon if your not looking for an authoritative solution. It’s an easy to use and popular library that has quite a few users offering support. Latency is reasonable pending on geography. But, that’s an issue your are going to have with almost any network library. I wouldn’t think you would need to send 10 msg/second if you are only sending game commands.

    I haven’t used LiteNetLib, but it seems like you need to host it yourself. And it looks like you need to script your own lobby/matches and storage options. Also, you have to deal with firing up a bunch of servers around the world and monitor them yourself. And if your game has success, you are going to need the ability to scale out.
     
    Valkrysa_Herja likes this.
  3. Valkrysa_Herja

    Valkrysa_Herja

    Joined:
    Aug 1, 2014
    Posts:
    41
    Thank you for your link and info Voncarp :)

    As to the message rate, traditionally RTS style games that use a lockstep mechanism send a very small no-commands message if on any given 100ms "turn" a player has no commands to send. Just so that the rest of the peers can know that the given player isn't lagging out. (and if they are lagging out and aren't sending this message the other clients know to pause the game temporarily after enough missed "turns")
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    In my experience, even at around 500 messages per second, there aren't any problems, so at 360 I believe you should be absolutely fine.
     
    Valkrysa_Herja likes this.
  5. Valkrysa_Herja

    Valkrysa_Herja

    Joined:
    Aug 1, 2014
    Posts:
    41
    Thank you very much Munchy, it is reassuring to hear :)
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    When you use PUN and PhotonViews and RPCs, you may end up with more messages/second than you set out to send. This is because PUN will try to keep objects in sync for you.

    If you wanted full control of what gets sent and received, you'd ignore the PhotonViews and simply send all messages with PhotonNetwork.RaiseEvent or you use Custom Properties to update values.
    This is maybe of interest: https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state
     
    Valkrysa_Herja likes this.
  7. Valkrysa_Herja

    Valkrysa_Herja

    Joined:
    Aug 1, 2014
    Posts:
    41