diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index c75564869bf..6d5924be4c9 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -20,7 +20,6 @@ public enum SyncMode { Observers, Owner } /// Some of the built-in components of the networking system are derived from NetworkBehaviour, including NetworkTransport, NetworkAnimator and NetworkProximityChecker. /// [AddComponentMenu("")] - [RequireComponent(typeof(NetworkIdentity))] [HelpURL("https://mirror-networking.com/docs/Guides/NetworkBehaviour.html")] public abstract class NetworkBehaviour : MonoBehaviour { @@ -147,7 +146,7 @@ public NetworkIdentity NetIdentity // instead of calling unity's MonoBehaviour == operator if (((object)netIdentityCache) == null) { - netIdentityCache = GetComponent(); + netIdentityCache = GetComponentInParent(); // do this 2nd check inside first if so that we are not checking == twice on unity Object if (netIdentityCache == null) { diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 45ed1714bd5..24729449057 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -205,7 +205,7 @@ public NetworkBehaviour[] NetworkBehaviours if (networkBehavioursCache != null) return networkBehavioursCache; - NetworkBehaviour[] components = GetComponents(); + NetworkBehaviour[] components = GetComponentsInChildren(true); if (components.Length > 64) throw new InvalidOperationException("Only 64 NetworkBehaviour per gameobject allowed");