Questions about sending data with networkviews and ipunobservables.

Options
It has been awesome turning my game into a multiplayer one in a matter of days, but before I get too deep into finishing It I'd like to know about optimization of observable components and such.

In my two player game, each player controls a set of units. To sync the unit positions and stats, I created my own IPunObservable class instead of using the TransformView. It sends the unit's 2 dimentional position along with rotation in a single Vector3, health as a float, a few ints for data, and a bunch of booleans.

It all works fine, but how could I optimize it to allow for 10-30 units for each of my 2 players

In my list below by saying 'better' i mean does it use less of the network, does it send less data, is it faster, Does it result in less messages sent per minute, is it the best solution

1. Is doing stream.SendNext() less better, or does it not matter?
2. Is sending a byte better than sending a bool? is sending another object type better?
3. Is sending all my bools as a single int and determining on the other player's side what bools were true (for example if first digit is a 1, boolean1 is true and if the tens digit is a 1, then boolean2 is true, etc)
4. Is sending data only when it changes better? (I assume so)
5. Are more networkviews that send a little bit of information each better, or a few network views that send a lot of information.
6. Are networkviews that don't observe anything but just send rpcs bad? Do they create any sort of network latency when they aren't syncing anything.

I'm asking all of this because I don't know how photon sends data and if i should optimize and think about it, or if photon does that automatically.

Thanks in advance for any help, and excuse me if i missed something on the docs explaining how this works.


Also if you don't mind me asking, (if you are a developer using photon in in one of your published games especially mobile) how stable are your ccus? Do they change a lot dramatically even if you have small audiences? What are your relative max and min ccu counts throughout the day? Thanks.

Comments

  • jeanfabre
    Options
    Hi,

    Indeed, you should always be careful with the data you send across PUN, it's critical for good operation and performances.

    Before you read this, one very important thing is to always make the feature you need for your gameplay, and then look for optimization, else you'll be waisting time and constraint yourself more than you would like to. so be careful with putting forward optimization before actually having something that works in the first place and is fit for the job.

    1. stream.SendNext() is used even in the photonTransformView, this is the base of data synchronization, so if you want to create your custom data synch, you'll need this.
    2. you'll be fine with a bool, but yeah, for optimum bandwidth, bytes will be better.
    3. it's a good idea to do this yes, if I have many many bools, it would make sense.
    4. yes, always better to send just what you need, when you need it
    5. I think, it doesn't make a difference for a single networkviewID, it's all combined under the hood. but for maintenance, you may want to consider having only one script dealing with data synch, it's easier to debug I feel.
    6. nop, it's fine, but again, why creating multiple networkviews, only one should be enough, and have the various components of your prefab all have a pointer to your networkview and work that way.

    Bye,

    Jean
  • amzin7000
    amzin7000
    edited June 2016
    Options
    That was exactly the information I was looking for, thanks a lot Jean!
    I created a ByteHelper class and now i'm syncing 5 booleans and a small int with only one byte in a sendnext()!
    Whelp I should get back to work if I want to ever finish this.

    Cheers!