Hey,
let’s start with a basic assumption:
The less networked objects (NetworkBehaviours) are used within a scene, the less network bandwidth is consumed.
-
Is this assumption true? If so, under which conditions?
-
How significant is the actual number of NetworkBehaviours, independent from the synched data they include? Independent from the data means that we still have the same amount of SyncVars, Commands and ClientRPCs, but a different architecture respectively a different number of networked objects.
-
Do empty NetworkBehaviours (without data) have an impact on bandwidth consumption?
-
To which extent is it reasonable to reduce the number of NetworkBehaviours in order to optimize network bandwidth consumption?
Unfortunately, the official UNET docs do not provide much help and information on best practices regarding efficient UNET game architectures. In addition, everything would be so much easier if we had a way to exactly measure bandwidth consumption. Then we could at least compare different code architectures in terms of network bandwidth consumption. Anyway, it would be better to know how to do it properly right from the start.
A simple example:
Let’s say we have a game scenario with multiple players and each player is able to cast different spells.
Design Choice A:
We could make each spell a NetworkBehaviour with it’s own Commands and ClientRPCs. As a result, we have some quite modular code, but also a lot of networked objects in the scene (one for each spell and maybe also for each player).
Design Choice B:
We could change the code architecture to have a single NetworkBehaviour script for each player. This script handles all the Commands and ClientRPC and then calls functions in other scripts for the spells which do not need to be networked objects. So we have significantly less networked objects in the scene. On the downside, we might need a few more parameters in order to identify the casted spells.
So, these are just 2 design variants with different code architectures.
Is there a significant difference between those variants, especially in terms of bandwidth?
What are general hints and best practices in order to create efficient network architectures with UNET, especially in terms of bandwidth consumption?
Any help is much appreciated.