PUN architectural strategy


I am working on a project where we need about 200 GameObjects per player, (max 2 players, so a total of about 400-500), to sync their position and rotation. Is this too much to have a PhotonView component per GameObject?
If ("yes")
What is a better strategy?

Note: some of these GameObjects are grouped in about 20 groups per player. Should those 20 objects instead report their children objects change of position & rotation?


  • Bump?
  • I have the same problem
  • Any answer here please?
  • Still looking for this. I would appreciate an answer please.
  • Only for say something that can work...

    Try to do a Script observed by photon in the parent of all objects managed by the player, and use onSerializeView to synchronize all the childs that have change their values. You will have only 4 photonViews.. i think. I suggest to found a better solution that synchronize so much objects one to one. Sorry for my english and good luck
  • Hi @MrSueko,

    Thank you for choosing Photon!

    If I understood the question right:

    in a 2 players room, each player needs to control and synch. over 200-250 GameObject, should I:

    a. use a PhotonView on each GameObject?


    b. use few PhotonView to control many GameObject(s) at once

    if (b.) how should I group/structure GameObjects in the prefab hierarchy so we could synch. rotation & position of each GameObject of that group?

    My opinion (or thinking out loud):

    I would go for a. since it's easier to synch. each GameObject's position/rotation individually
    it's also OK and within PhotonView limits
    but we need to profile traffic usage
    how often do those GameObjects change?
    how often we should send updates?
    but since we are going to send to one player only
    so worst case is 250 * F * 2 * 2 / second / room (F is send rate)
    1000 F messages per second per room
    unless we group many updates into fewer messages, I don't know how to calculate that
    and we have other messages or other events ongoing

    My colleague @Tobias who is the lead PUN developer believes b. is the way to go. But he recommends a custom solution that involves optimized data exchange based on diff data only (quoting from slack):

    About syncing 250 objects each for 2 players:
    I think that PUN does not cover this case well. Aggregation and optimization of sent values is not good for this amount of views, so I would suggest to customize the solution.
    It makes sense to track per object which updates need to be synced and to write all values in an optimized way.
    While you could use PhotonViews to organize and track networked objects, I would probably have some logic that tracks all the changes and writes the minimal amount of data into a byte[] to send that.

    You could apply a lot of tricks per value to optimize that (quaternions can be sent in less than 4 floats, eg.) and you could also skip updates of values and entire objects, if there was no significant change.
  • Thanks for the reply! I will then either: limit frequency, or go with B and implement a personalized solution.
Sign In or Register to comment.