Hi. Sorry about my english.. I've two GameObjects, "Unit" and "UnitDestination". "UnitDestination is a child of "Unit". I want to acces to "UnitDestination" transform from a script attached to "Unit" gameobject. I tried this: Code (csharp): private Transform destination; void Awake() { destination = GetComponentInChildren<Transform> (); Debug.Log (destination.name); } but console debugs "Unit", not "UnitDestination". I don't understand why doesn't work.. any help?
GetComponentInChildren is a somewhat misleading name, because the API doc explains that it searches the current object or its children: https://docs.unity3d.com/ScriptReference/Component.GetComponentInChildren.html For your situation though it makes more sense to get this.transform.GetChild(0);