GetComponentsInChildren bugged?

When i use " GetComponentsInChildren < Transform > ();" it also adds parent’s transform to that array, is this a bug or intended behaviour? Also how can i only get and set transform in children and not parent?

Returns all components of Type type in the GameObject or any of its children

Intended.
You could try converting it to a list, and removing the one you don’t want

T[] array = GetComponentInChildren<T>();
List<T> list = new List<T>(array);
list.remove(GetComponent<T>());
//optionally:
array = list.ToArray();
1 Like
Transform[] children = GetComponentsInChildren<Transform>().Where(t => t != transform).ToArray();