- Home /
How do NetworkIdentity and Hierarchy interact?
There is documentation about the NetworkIdenty-Component: https://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.html
It says:
For complex objects with a hierarchy of subcomponents, the NetworkIdentity must be on the root of the hierarchy. It is not supported to have multiple NetworkIdentity components on subcomponents of a hierarchy.
This does seem to be specific... but it confuses me a lot:
1) Originally I assumed that this meant/impied:
"An object with NetworkIdentity cannot be child of an object which also has a NetworkIdentity."
Now I tried such a situation - and it did not cause any noticable problems. No errors, no warnings, and preexisting functionality worked.
a) Will problems turn up later / only in specific situations?
b) Did I missunderstand and it actually is allowed to have a NetworkIdentity as child of a NetworkIdentity?
2) First sentence:
For complex objects with a hierarchy of subcomponents, the NetworkIdentity must be on the root of the hierarchy.
Read as written, the statement cited above seems to imply the following:
Any object that has at least one child-object could be seen as a "complex object with a hierarchy". Therefor no object with a NetworkIdentity may ever have any other parent than the scene itself.
That, too, seems to be bogus. It does not seem to cause problems to have networkIdentities in some kind of group...
a) Is read-as-written wrong for this documentation?
b) Are there some problems that will come to haunt my team later?
c) Am I missunderstanding the documentation due to a lack of language-skills?
d) Are we missing something else?
3) Second sentence:
It is not supported to have multiple NetworkIdentity components on subcomponents of a hierarchy.
Now this second sentence speaks about multiple NetworkIdentities. Will there only be a problem when I have several of these a children of any other object? Or is that something that I got wrong, too?
Update: I finally got some warnings and errors. The Server is giving me the warning
Prefab 'DeviceDemonstrator' has several NetworkIdentity components attached to itself or its children, this is not supported. UnityEditor.Build.BuildPipelineInterfaces:OnSceneProcess(Scene, Boolean)
The client at the same time gives me the the following error lots of times:
IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:7 pos:7 UnityEngine.Networking.NetBuffer.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBuffer.cs:35) UnityEngine.Networking.NetworkReader.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:165)
I have not yet found out what finally triggered those errors... Or, to be more exact: I have not yet found out why those errors had not been triggered before.