You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
When you have a NetworkBehavior which has children with other NetworkBehaviors, there is a chance the children are not initiated correctly.
This issue only happens when the function NetworkManager.CaptureObjects(NetworkObject obj) process the children before their parent. For some reason this seems to be an issue for new connecting players, when they receive all the created instances at the same time.
When the parent is processed first
The parent NetworkObject is processed in the NetworkManager.CaptureObjects function and a new instance is created for its NetworkBehavior. When its NetworkBehavior is initialized, it adds its children NetworkBehavior to the NetworkBehavior.skipAttachIds static dictionary (which is done in the NetworkBehavior.ProcessOthers function)
When the children NetworkObject are processed in the NetworkManager.Capture they find themselves on the skipAttachIds dictionary, attaching the networkObject to the already instantiated NetworkBehavior.
When the children is processed first
The children NetworkObject is processed in the NetworkManager.CaptureObjects function and a new instance is created for its NetworkBehavior. The NetworkObject is now part of this new NetworkBehavior instance.
The parent NetworkObject is processed in the NetworkManager.Capture function and a new instance is created for its NetworkBehavior. When its NetworkBehavior is initialized, it adds its children NetworkBehavior to the skipAttachIds (which is done in the NetworkBehavior.ProcessOthers function)
The children NetworkBehavior are left without a NetworkObject, and the skipAttachIds is left with the children's NetworkBehavior inside.
Possible solution
There should be a way to guarantee that the NetworkObjects are processed by the NetworkManager.CaptureObjects in a way that the parents are processed first.
I'm not 100% sure about this, but I think this depends on the order in which the NetworkObjects are stored in the NetWorked.pendingCreates when the NetWorked.Flush() function is called.
The text was updated successfully, but these errors were encountered:
When you have a
NetworkBehavior
which has children with otherNetworkBehaviors
, there is a chance the children are not initiated correctly.This issue only happens when the function
NetworkManager.CaptureObjects(NetworkObject obj)
process the children before their parent. For some reason this seems to be an issue for new connecting players, when they receive all the created instances at the same time.When the parent is processed first
The parent
NetworkObject
is processed in theNetworkManager.CaptureObjects
function and a new instance is created for itsNetworkBehavior
. When itsNetworkBehavior
is initialized, it adds its childrenNetworkBehavior
to theNetworkBehavior.skipAttachIds
static dictionary (which is done in theNetworkBehavior.ProcessOthers
function)When the children
NetworkObject
are processed in theNetworkManager.Capture
they find themselves on theskipAttachIds
dictionary, attaching thenetworkObject
to the already instantiatedNetworkBehavior
.When the children is processed first
The children
NetworkObject
is processed in theNetworkManager.CaptureObjects
function and a new instance is created for itsNetworkBehavior
. TheNetworkObject
is now part of this newNetworkBehavior
instance.The parent
NetworkObject
is processed in theNetworkManager.Capture
function and a new instance is created for itsNetworkBehavior
. When its NetworkBehavior is initialized, it adds its children NetworkBehavior to theskipAttachIds
(which is done in theNetworkBehavior.ProcessOthers
function)The children
NetworkBehavior
are left without aNetworkObject
, and theskipAttachIds
is left with the children'sNetworkBehavior
inside.Possible solution
There should be a way to guarantee that the
NetworkObjects
are processed by theNetworkManager.CaptureObjects
in a way that the parents are processed first.I'm not 100% sure about this, but I think this depends on the order in which the NetworkObjects are stored in the
NetWorked.pendingCreates
when theNetWorked.Flush()
function is called.The text was updated successfully, but these errors were encountered: