Transform.Find can be used to locate other Transforms in the hierarchy.

Searching Underneath a Transform

We can use Transform.Find on one Transform to search underneath it. Here we use it to search underneath Foo, find Bar, and re-parent Subject to be underneath it:

Taking this a step further, we can use slashes (/) to add more transforms to our search. By typing Bar/Baz, we can crawl down the hierarchy from Foo β†’ Bar β†’ Baz:

Searching Underneath the Root of the Hierarchy

A lot of the time, we’ll actually want to search down the root of the hierarchy, instead of relative to another Transform (So underneath our scene - Marrow Template Scene instead of Foo in this case).

To do this, insert a / to the start of the path. This works with any Transform we run the Find method on!

No matter what Transform we feed into the call, putting a / at the start will always make it search underneath the root of the scene.

Searching the Parent of a Transform

Need to crawl up the hierarchy instead of down? Adding ../ to the path will tell Unity to go backwards.

In this example - parenting under BONELAB’s Flashlight spawnable and invoking this Event can be used to turn it on:

Unfamiliar with SendMessageUpwards? Check out 1.2 NPC Despawning Zone!