UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1

Trigger

A  trigger is a zero-sized node that has no visual representation and fires callbacks when it is enabled/disabled (an enabled callback function is called) or its transformation is changed (a position callback function is called). The trigger node is usually added as a child node to another node, so that the callbacks will be fired on the parent node enabling/disabling or transforming.

Notice
The enabled and position callback functions should be implemented in the world script.
The trigger nodes can work with procedurally created world cluster and world clutter objects. For example, a trigger node can be added as a child to a node that is baked into a world cluster in order to fire the enabled callback when the cluster renders this node (i.e. enables it).

The trigger node can be used, for example, to play a sound of thunder when a lightning flashes: when a lightning node is enabled, the enabled callback function that plays a sound is called

Lightning Node Enabled

See also

Adding a Trigger Node

To add a new trigger node via UnigineEditor, click Create -> Node -> Trigger on the Menu bar and then place the trigger node in the world.

Place a Trigger Node

Then you should add the trigger node as a child to a node for which callbacks should be fired: select the trigger node in the Nodes panel, hold Alt and drag it inside the required node. For example:

Adding Trigger Node as a Child Node to a World Cluster

Editing a Trigger Node

To edit the trigger node, select it and go to the Trigger tab of the Nodes panel. On this tab, you can specify the callback functions that will be called when the node trigger or its parent node is enabled/disabled or transformed.

Trigger Node Settings

The callback functions must be implemented in the world script. The enabled and position callback functions should receive a trigger node that fired the callback as its first argument. However, they can also receive no arguments.

Notice
The callback function can also take 2 additional arguments. However, you can set such callbacks via the code only. Via UnigineEditor, you can only specify the callback functions that receive 0 or 1 argument.
Last update: 2017-07-03