-
Notifications
You must be signed in to change notification settings - Fork 0
What are Network Identifiers and how important are they
- What are Network Identifiers and what they are used for.
- What not to do with a Network Identifier.
- How Maploader uses Network Identifiers.
A Network Identifier in Mirror is just the netId that Mirror gives to every networked object so the server and clients know which object is which.
A network object is what the server uses to control, synchronize, and spawn over the network. Without the network identifier, networked objects will not function as normal.
A networked object will be the following:
_Evnrionment-
Portal(a portal that transitions you to another scene) MapInstance-
NetNPC
And so on...
Mirror assigns these objects with a NetID. These NetIDs are very useful in terms of rather or not the object in question is a Network object or not.
In Maploader, these objects can range from either a Portal or a MapInstance as these components are required to have a Network Identifier / NetID to function. Without the NetIDs, these portals will not function correctly in multiplayer as a client. and will give off an error in the console. (In singleplayer, these are not used as in the game, you are simple a local player).
For more information, visit Mirror's documentation of Network Identity
A network object we can use as an example is the Portal component.

In unity, these are listed as _entity_portal. In this case, we will use the portal for Sanctum Arena _entity_portal (Assets/Scenes/map_pvp_sanctumArena.unity -> spawnPoint)
In the inspector to the right of Unity, we can see that this gameobject is using a Network Identity component, a Portal component, as well as the Sphere Collider. This immediately tells as that the gameobject we are currently using requires a NetID to function.
For a more technical look, here's part of the code that is used for the Portal component. (ILSpy is simple a decompiler. 100% of the code is not represented correctly and may include errors)
using System.Runtime.InteropServices;
using Mirror;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Portal : NetworkBehaviour
{
[Header("Portal Parameters")]
public ScenePortalData _scenePortal;
[Space]
[SyncVar]
public bool _netDisablePortal;
public bool _isPortalOpen = true;
public bool _disableIfSoloMode;
[Header("Visual")]
public GameObject _portalVisualContainer;
public ParticleSystem _portalEffect;
private AudioSource[] _aSrcCache;Immediately we can see that this component is using Mirror as well as public class Portal : NetworkBehaviour. This confirms that this component is indeed required to have a NetID.
To simply use this object, this object MUST NOT be inside of the _Environment gameobject parent as that object is also a Networked object.
you should not mess with anything inside of the component. Asset ID, Visibility, etc etc. Leave it alone.
When you have the object in your scene, you are allowed to do anything you want with it as long as both the Network Identity component is left in place.
When you are done with said object, you can test your map in multiplayer to see if the client user (your friend or maybe Marioalexsan) can enter the portal just fine.
You shouldn’t modify the Network Identity component in the Inspector, and you also shouldn’t duplicate objects that share the same Network Identity data. Mirror assigns each networked object a unique NetID at runtime, and if two objects with the same identity appear in the same scene or during a transition, Mirror’s safety checks will disable them.
This is why, for example, entering a map that shares the same Network Identity setup as another map can break the transition. When both versions of the object appear at once, Mirror detects the duplicate NetIDs and prevents them from functioning.
Example from Wolfkann:
...So, if, "My Cool Zone #1" uses "arcwood pass" mapinstance copy, "Cooler Sub Zone" can't use "My Cool Zone#1" or "arcwood pass" mapinstance copy.
To prevent this issue, you need to place a vanilla network object of another object that isn't a copy of the same object into your scene. These objects already come with valid Network Identity data, including a proper NetID, which the MapLoader cannot generate on its own.
Repeat this process for every Portal, MapInstance, or _Environment you plan to use. Doing so ensures each one has a unique identity and prevents duplicated NetIDs from appearing in the same scene or during transitions.
It's pretty easy however a bit annoying to understand. That's why we rely on asking other map developers for help in case any of this seems very confusing. Happy Mapping!
Take Note!
If you need more information regards to mapping or maploader bug reporting, consider making a report in Issues.