Orx provides a pair of functions for finding objects in an object hierarchy by name. The two functions are orxObject_FindChild
and orxObject_FindOwnedChild
. These functions will filter out any camera or spawner and retrieve the child matching the provided path.
Paths are composed by object names separated by .
. A wildcard can be used *
instead of a name to find children at any depth inside the hierarchy, using depth-first search. Lastly, C subscript syntax, [N]
, can be used to access the N+1th (indices are 0-based) object matching the path until there.
For example:
orxObject_FindChild(pstObject, “Higher.Lower”);
will find the first child named Lower of the first child named Higher of pstObjectorxObject_FindChild(pstObject, “Higher.*.Deep”);
will find the first object named Deep at any depth (depth-first search) under the first child named Higher of pstObjectorxObject_FindChild(pstObject, “*.Other[2]”);
will find the third object named Other at any depth under pstObject (depth-first search)orxObject_FindChild(pstObject, “Higher.[1]”);
will find the second child (no matter its name) of the first child named Higher of pstObject