First, we create an array of GameObjects (any object that inherents a Transform) for anything we want to be detected by Raycasts.
Then, we pass this array of created GameObjects into the constructor for the HeirarchicalVolumeManager object to create a Bounding Volume Hierarchy (BVH).
This builds a BVH and organizes all of the passed GameObjects into the tree. Now searching for raycast interception is a lot less costly (before searching would take O(n), but now its averaged at O(log(n))).
To cast a ray, we first create a new Raycast object and
then provide the start point and end point of the raycast (in World Coordinates [x,y]).
To check if the raycast has intercepted any objects just call the
update(headNode) function to get a list of all the
objects it intercepted.
headNode is simply the HeirarchicalVolumeManager.getHeadNode().)
Now we can use this array of intercepted GameObjects and use them in any way we wish.