[Unity Pun] How to handle big amount of objects?

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

[Unity Pun] How to handle big amount of objects?

zaki
2018-07-10 09:21:39

Hello, I would like to seek advise on how to handle big amount of game objects that need to be synced over network.

We have an app to load a big building (imagine a 50 storey hotel). The building consists of hundreds of small rooms. Each room has properties like sofa, tv, tables, chairs etc. We need to sync the properties, for example user-A move the chair-a, all others user should be able to see the chair-a is moving its position and rotation.

Whats the best way to handle such amount of game objects?

  1. The easiest way is to spawn each of the interactable properties using PhotonNetwork.Instantiate (each will have its photonview), using photon transform follow component to sync its position and rotation. However, is this even possible? Is there any limits of how many objects can be spawned in a scene? Will this cause massive lag?

  2. RPC/Event Method. Whenever user-a do an action, send an event/rpc to all users and update its position and rotation.

We are using, 100 CCU plan, 500 Msg/s per Room.

Please advise.
Thanks.

Comments

[Deleted User]
2018-07-10 15:18:57

Hi @zaki,

1. [...]

This isn't a good idea. Although the limit of PhotonViews per client is 1000 per default, this doesn't mean that you should use them all. Instead you should avoid having too many PhotonViews at all, since they might cause a lot of messages and network traffic.

2. [...]

This is a better idea. Let me give you some additional input, which came into my mind while reading this topic. My approach would be to add a certain manager to each floor of the building. This manager handles the synchronization of the objects which can be moved. Therefore the manager has an overview about all objects on his floor. The objects in this case have an unique ID each. When a player now moves object A to position B, he notifies the manager which then synchronizes those changes with the other players. This can be done with RPCs or by using the RaiseEvent function. In both cases, the manager creates a message which has the performed action as content, for example: Object A moved to position B.

zaki
2018-07-11 09:30:21

Hello @Christian_Simon ,

Thanks for the reply. I will try that out.

Back to top