Flocking GetFlocker(Transform parent) { var flockers = parent.GetComponentsInChildren <Flocking>(); foreach (var f in flockers) { if (LayerUtil.IsInMask(f.gameObject.layer, targetLayer)) { return(f); } } return(null); }