I'm trying to get descendant game object, not a child. Let's assume that I have a GameObject and it's hierachy looks like this:
Weapon
- Hands
- metarig
- upper_arm.L
- upper_arm.R
- forearm.L.001
- hand.L.001
- weapon.L.001
- AttackDetection(!)
- Sword
I want to access "AttackDetection" from Weapon(Root) in script. But when I try this:
void Start() {
attackDetectionGObject = this.transform.Find("AttackDetection").gameObject;
}
It fails with this:
NullReferenceException: Object reference not set to an instance of an object
Looks like transform.Find just looking up it's own child, not descendant. I try to find way to solve this problem, but there's nothing I found.
Any advice will be very very appreciate it.