Behavior Triggers

Creating a CrowdTrigger can be performed through the following options:

  • Crowd Shelf: 
  • Crowd Menu: CrowdTrigger Node
  • MEL command: glmCrowdTriggerNodeCmd;

Note that most often it is useless to create a Trigger manually because two triggers will be automatically created when creating a Behavior.

Configuration

General Attributes

This part describes the available General Attributes:
 
General attributes if a trigger
 
Trigger Operator Multiple trigger attributes can be activated in a Trigger. The trigger operator is the operator used to aggregate all trigger attribute results and compute the final result of the Trigger (e.g. if the AND operator is used and 3 trigger attributes are activated, then the Trigger result is [Trigger1 AND Trigger2 AND Trigger3], meaning that it will not return true until all the triggers are not true at the same time). The available operators are AND, OR, XOR.

Trigger Attributes

This part describes the available Trigger Attributes:
 
Trigger attributes of a trigger node
 
To activate a type of trigger, it is needed to check its box. If several boxes are checked, the resulting trigger will be the conjunction of the active triggers using the chosen trigger operator (see above).
 
Random Trigger
The Random Trigger enables to start or stop a behavior by returning true X times on Y frames.
 
Note that if 1000 characters use this trigger over 1000 frames, to have around one character starting the behavior over the whole sequence, one should use X=1, Y=1000.
 
This attribute is influenced by the random seed of the Crowd Manager
Current Frame Trigger
The Current Frame Trigger enables to start or stop a behavior by returning true if the current frame is successfully compared to a reference value. There are two input values:
  • A comparison operator (equal, greater than…);
  • A reference value.
Zone Trigger

The zone trigger enables to start or stop a behavior by returning true when the position of a particle representing an Entity is contained in a zone (the zone being represented by a Maya mesh). There are three input values:

  • Zone: Link to the Maya mesh to check as a zone. To know how to map two nodes, please refer to the part 5.8.1
  • !: It enables to check if the character is NOT in the zone, instead of checking if it is in the zone
  • 3d: It enables to check if the character root is inside the volume of the mesh, instead of checking if the projection of the root is in the zone
This trigger can be useful to create a wave in a stadium, or to have characters jumping when crossing a small river.
Distance Trigger
The distance trigger enables to start or stop a behavior by returning true when the distance between a particle representing an Entity and an object (camera, mesh…) is successfully compared to a reference value. There are three input values:
 
  • Distance object: Link to the Maya object to check the distance with. Notice that, if the object is a mesh, the distance will be computed with its Maya AABB. To know how to map two nodes, please refer to usual manipulations
  • A comparison operator (equal, greater than…)
  • A reference value
Driven Attribute Trigger
The Driven Attribute Trigger enables to start or stop a behavior by returning true if any Maya object attribute is successfully compared to a reference value. There are three input values:
  • The driven attribute value: the current value of the linked Maya object attribute;
  • A comparison operator (equal, greater than…);
  • A reference value.

To link a Maya object attribute with the driven attribute:

  • select the target object and the corresponding trigger in the Outliner / Open the Connection Editor (Window / General Editors / Connection Editor)
  • Make sure that the target object is displayed in the Outputs column and that the trigger is displayed in the Inputs column (if not, press the "from->to" / "to->from" button).
  • In the Outputs column, select the wanted attribute to link and, in the Inputs Columns, select drivenAttribute.
  • Now, the driven attribute value field in the trigger will display and be updated with the value of the linked attribute, even if the linked attribute is animated

It can be particularly useful to adapt a behavior to the environment or any event in Maya. E.g. one could create an explosion particle system, link its visibility attribute to a flee behavior. Then, when the explosion object will be displayed, the entities will flee from it.

PPAttribute Trigger
The PPAttribute Trigger enables to start or stop a behavior by returning true if a per-particle field is successfully compared to a reference value. There are three input values:
  • PPAttribute Name: the name of of the per-particle field to check
  • A comparison operator (equal, greater than…)
  • A reference value.
Behavior Time Trigger
The motion time trigger enables to stop a behavior by returning true when a motion has been played for a certain amount of time. There are 3 input values:
  • %: the trigger will return true if X% of the length of the motion is reached;
  • sec: the trigger will return true if the motion has been played for X seconds;
  • frames: the trigger will return true if the motion has been played for X frames.
The resulting time for testing is the sum of the percent parameter, the seconds parameter and the frames parameter.
 
This trigger has no meaning as a starting trigger, as the behavior has not yet run.
The % mode has meaning only for the Motion Behavior.
Script Cmd Trigger
The script command trigger enables to start or stop a behavior by returning true when the MEL or Python command returns a value different than 0. There is only one possible input value, which is a string representing the script command.
 
  • Example: The following MEL command counts and returns the number of entities in a circle of radius 2 maya units, located at the center of the scene. The trigger will return true if this number is not 0:

spatialRequest -center 0 0 0 -radius 2 -type count;

This trigger can be useful when dealing with complex conditions or to execute a specific MEL or Python code during the simulation. The script command may contain two special tags (#pid# and #ps#) to interact with particles (see Technical Documentation ).
 
For example, if the user defines the function:
global proc int startBehavior(string $particleSystem, int $particleId)
To call this function with the current particle, the MEL command to use is; startBehavior("#ps#", #pid#)
True/False triggers

True: Always returns true. It is the default starting trigger of each behavior (i.e. a behavior always starts);

False: Never returns true. It is the default stopping trigger of each behavior (i.e. a behavior never stops);

Callback Attributes

The OnSucces Callback is a script command run each time the trigger is evaluated to "true" (when a behavior is started or when it must stop).
 
Trigger on success callback
 
This callback may contain two special tags (#pid# and #ps#) to interact with particles (see Technical Documentation ).
 

Trigger Hierarchy Attributes

This part describes the available Trigger Hierarchy Attributes:
 
Trigger hierarchy attributes of a trigger node
 
It is possible to map triggers together, in order to use the result of another trigger as a part of the trigger result. The mapped triggers are evaluated and their results combined together with the current trigger checked trigger attributes thanks to the trigger operator (see above).
 
Mapping triggers with others can be helpful to reuse existing triggers or building complex triggers. As an example, let's imagine a scene with a soldier approaching an enemy base.
 
Let say that we already defined two existing triggers built for other purposes:
  • isInCriticalZoneTrigger: returns true if the soldier is close enough or inside the enemy base;
  • someoneDetectedTriggerNode: returns true if someone is near the machine gun located at the center of the base;
      
IsInCriticalZoneTrigger and SomeoneDetectedTrigger
 
Now, if you want to build a crouch behavior in order to play a crouch motion if the soldier is in the critical zone AND someone is located near the machine gun, instead of building a new trigger from scratch, you can just link the two existing trigger in your mustHide Trigger.
 
mustHide trigger
 
The mustHide trigger will evaluate the isInCriticalZoneTrigger, the someoneDetectedTrigger and compute the resulting value using the AND operator.