Unity Mirror - GameObjects

Unity Mirror - GameObjects

Unity Mirror - GameObjects

 Network-based GameObjects are game objects controlled and synchronized by Mirror's network system. By using synchronized network-based game objects, you can create a shared experience for all players playing an instance of the game. Players see and hear the same events and actions, even from their own unique perspective within the game.

Multiplayer games in Mirror are generally created using scenes that include both network-based and regular (non-network-based) game objects. Network-based game objects are those that move or change during gameplay and need to be synchronized among all users playing the game together. Non-network-based game objects are objects that never move or change during gameplay (such as static obstacles like rocks or fences), or objects with movements or changes that do not need to be synchronized between players (for example, a gently swaying tree or clouds passing in the background).

A network-based game object is an object to which a Network Identity component has been added. However, the Network Identity component alone is not sufficient for your game object to be functional and active in multiplayer gameplay. The Network Identity component is the starting point for synchronization and allows the Network Manager to synchronize the creation and destruction of the game object, but beyond that, it does not specify which features of your game object should be synchronized.

Which features of which network-based game object should be synchronized depends on the type of game you are making and the purpose of each game object. Some examples that you may want to synchronize are:

  •  The position and rotation of moving game objects, such as players and AI characters.
  •  The animation state of an animated game object.
  •  The value of a variable, such as how much time is left in the current round of the game or how much energy a player has.

Some of these can be automatically synchronized by Mirror. The creation and destruction of synchronized network-based game objects are managed by the Network Manager and are known as the Spawn process. You can use the Network Transform component to synchronize the position and rotation of a game object, and the Network Animator component to synchronize the animation of a game object.

You need to use scripts to synchronize other features of a network-based game object. For more information on this, you can refer to the "State Synchronization" documentation.