Node Copied to Clipboard!

Distance Helper Node

The distance helper node has two functions that can be used to trigger an event when two objects are within or outside a certain range of each other.

Wait Until Within Range

The Wait Until Within Range node is a function of the Distance Helper node. It will detect when two objects are within the specified range of each other.

In this example we will show you how to use the distance helper to display a message box when the main camera is within range of the cube.

Right-click on the storyboarder and select the Distance Helper node.

Dereference the Wait Until Within Range node from the Distance Helper.

Drag the main camera from the scene hierarchy to the First parameter of the Wait Until Within Range node.

Drag the cube model from the scene hierarchy or editor window into the second parameter.

Right-click in the range parameter and select float(constant).

Change the value of the float to 2 in the properties tab.

Connect the node to the main flow of execution.

Drag the Main camera from the scene hierarchy to the storyboarder.

Dereference a Start Free Flight node and attach it to the flow of execution before the distance helper node.

Drag out the distance helpers right connector and add a MessageBox node. You can change the message in the properties tab.

When you simulate and play the lesson, as the player, you can move the camera around the scene and as soon as you are within range 2 of the cube the messagebox will be displayed.

Node

Wait Until Outside Range

Wait Until Outside Range can be used in the same manner as Wait Until Within Range, but it will wait for the objects to leave the specified range of each other instead of enter it.