World Trigger
A world trigger is a cuboid shaped object, which fires callbacks when any node (physical or not) gets inside or outside of it. The trigger can detect a node of any type by its bound object and can be used to access node's components and parameters.
- Dummy Node
- Node Reference
- Node Layer
- World Switcher
- World Transform Path
- World Transform Bone
- World Expression
- Dummy Object (if it has no body assigned)
See also#
- WorldTrigger class to manage World Trigger via API
-
A set of samples located in the data/samples/worlds folder:
- trigger_01
- trigger_02
- Videotutorial on How To Use World Triggers to Detect Nodes by Their Bounds
Creating a World Trigger#
To create World Trigger via UnigineEditor:
-
On the Menu bar, choose Create -> Logic -> World Trigger
- Place the node in the scene.
Editing a World Trigger#
In the Node tab of the Parameters window, you can adjust the following parameters of World Trigger:
Bounding Box Parameters#
A set of bounding box parameters:
Edit Size |
Toggles the editing mode for the World Trigger node on and off. When enabled, the bounding box sides that can be resized are highlighted with the colored rectangles. To change the size of a side, drag the corresponding rectangle. |
---|---|
Touch | Toggles the touch mode for World Trigger on and off. With this mode on, World Trigger reacts to the node at a partial contact. Otherwise, World Trigger reacts only if the whole bounding box gets inside it. |
Size | The size of the World Trigger bounding box along the X, Y, and Z axes, in units. |
Setting Up Callbacks#
To add an enter or leave callback, write a callback function that receives a Node as its first argument. Then use the addEnterCallback or addLeaveCallback method to specify the function to be called.
// add the enter callback to be fired when a node enters World Trigger
worldTrigger->addEnterCallback(MakeCallback(this, &AppWorldLogic::enter_callback));
// add the leave callback to be fired when a node leaves World Trigger
worldTrigger->addLeaveCallback(MakeCallback(this, &AppWorldLogic::leave_callback));
// add the enter callback to be fired when a node enters World Trigger
worldTrigger.AddEnterCallback(enter_callback);
// add the leave callback to be fired when a node leaves World Trigger
worldTrigger.AddLeaveCallback(leave_callback);