MLAPI Nested Objects or Network Behaviours?
My Xevious Boss is an object with five child, or nested, objects. To convert this into an MLAPI object I added a NetworkObject to each node, i.e. one for the root Boss and one each for the nested objects. When I instantiate the boss, or in MLAPI terms Spawn the boss, the root object would have a network Id but all the nested objects would just be set to zero. I have seen this before and I have previously worked-around the problem by making the root act as a relay/proxy for the children. But this time I was determined that each nested object should be responsible for itself and not rely on the parent knowing more than it should.
Network Object or Network Behaviour?
My problem was a fundamental misunderstanding about two important concepts, Network Object and Network Behaviour. When I convert a MonoBehaviour to be, “MLAPI aware” I change it to a NetworkBehaviour. For this to work I thought it requires an attached Network Object. However, when I tried to use the network API, e.g. call a ClientRpc method, it would not work — this was confirmed by asking for the network Id which would be 0.
Turns out my assumption was slightly off. If the parent (root) object has a Network Object then all the nested objects can just be NetworkBehaviours. More than that, the must NOT have Network Objects. As soon as I removed the Network Object component from the children everything started working.
PS. Thanks to _rmrtn on the MLAPI servers for pointing me in the right direction.