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). A Node Trigger 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.
The Node Trigger can be used, for example, to play a sound of thunder when a lightning flashes: when the lightning node is enabled, the enabled callback function that plays a sound is called.
- The NodeTrigger class to edit triggers via API
Adding a Node Trigger#
To add a new Node Trigger via UnigineEditor do the following:
Editing a Node Trigger#
To edit the Node Trigger, select it and go to the Node tab of the Parameters window. In the Node Trigger section, you can specify callback functions that will be called when the Node Trigger or its parent node is enabled/disabled or transformed.
The callback functions must be implemented in the world script (on UnigineScript side). The enabled and position callback functions should receive a Node Trigger that fires the callback as their first argument. However, they can also receive a node or even no arguments at all.