Start/Stop Behaviors with Triggers
Triggers control the start and stop conditions of each behavior. They are used to make Entities react to various events, such as an entity entering in a predefined zone, or being at a given distance of something else... This page details how to use each Trigger and gives some examples of when to use them.
Random Trigger
The Random Trigger enables to start or stop a Behavior randomly depending on a percentage.
Left: 10% of the Entities sit - Right: 50% of the Entities sit.
As the trigger is evaluated per character and per frame, the wanted percentage is not strictly respected, but will tend to be respected. In the example above, with a 50% of chance to trigger the Sit Behavior, 14 characters are actually sit (on 25 available) which represent 54% of the crowd.
Usually this Trigger is combined with other triggers to add variety and some *delay* to start or stop a behavior. If this Trigger is used alone, it will be evaluated at each frame until it returns true: it means that with a 50% Random Trigger, everybody will tend to be sat at frame 3:
"1 in 2" Random Trigger to start the Sit Behavior - Left: Frame 2 - Right: Frame 3.
To avoid this and have the Random Trigger only evaluated once, you can combine the Random Trigger with another Trigger occurring only once in a simulation (current frame is equal to 2 for example):
Random Trigger combine with a current Frame trigger equal to 2
Current Frame Trigger
The Current Frame Trigger enables to start or stop a Behavior depending on the current Maya frame. It provides a comparison operator (is equal to, is different to, is lower than...) and a value to compare to.
Current Frame Trigger "== 3" - Left: Frame 2 - Right: Frame 3
Polygon Zone Trigger
The Polygon Zone Trigger enables to start or stop a Behavior when the Entity is located in a Maya mesh. The Zone is represented by a Maya mesh, which can be animated and can be either planar or a volume.
Left: Example of a 2d Zone Trigger - Right: Example of a 3d Zone Trigger
Refer here to learn how to map a Maya mesh to a Zone Trigger.
This Trigger can be useful to create a mexican wave in a stadium, make Entities blow when touched by an explosion (represented by a volume mesh)...
Painted Zone Trigger
The Painted Zone trigger enables to start or stop a behavior by returning true when the position of the root bone of an Entity is contained in a painted zone of a specified color (the painted zone being represented by a Painted Zone Locator).
Left: Entities are in the Yellow zone - Right:Entities are not in a cyan zone
Texture Trigger
The Texture trigger enables to start or stop a behavior by returning true when the position of the root bone of an Entity is contained in a zone of a specified color of a Maya 2d or 3d Texture.
Left: Entities are in the Yellow zone - Right:Entities are not in a cyan zone
Distance Trigger
The Distance Trigger enables to start or stop a Behavior when the Entity is close enough / far enough to a Maya object. The Maya object can be anything, from a camera node (to deal with LOD) to a Maya mesh and can be animated. If the object is a Maya mesh, notice that the Distance Trigger works with the bounding box of the mesh and not the actual hull.
Refer here to learn how to map a Maya object to a Distance Trigger.
This Trigger can be useful to load a different LOD geometry depending on the camera distance, make Entities flee when they get close to a dangerous area...
Driven Attribute Trigger
The Driven Attribute Trigger enables to start or stop a Behavior when any Attribute of any Maya object reaches a specific value. The Attribute can be anything from a rotate component of a Maya mesh to the diffuse value of a shader. It can be keyframed, controlled with an expression or changed interactively by the user within Maya.
Left: Entities sit when the scale of the cube reaches 0.5 or less - Right: Entities sit when the red part of the color of the cube reaches less than 1 or more.
Refer here to learn how to connect a Maya Attribute to a Driven Attribute Trigger.
This Trigger can be useful to make Entities flee when a Maya mesh reaches a specific color or make Entities sucked up by an UFO when it starts spinning...
PPAttribute Trigger
The PPAttribute Trigger enables to start or stop a Behavior when an Entity PPAttribute reaches a specific value. The PPAttribute can be dynamic. Refer here to see how to easily set and control PPAttributes.
Left: Entities with a particle id PPAttribute less than 10 sit - Right: Entities with a myTriggerPP PPAttribute more than 70 sit (the PPAttribute value is incremented with a ChannelOperator Behavior).
This Trigger can be useful to kill Entities when their lifePoints PPAttribute reaches 0...
Expression Trigger
The Expression Trigger enables to start or stop a Behavior by returning true if the evaluation of an Expression or a Channel is successfully compared to a reference value. The Expression can be dynamic.
Left: Entities with a particle id PPAttribute less than 10 sit - Right: Entities playing "sit" behavior, stopped according to the currentFrame channel after playing 18 frames.
Behavior Time Trigger
The Behavior Time Trigger enables to stop a Behavior when this Behavior has been played for a specific time. The time can be expressed in frames, seconds. The time corresponds to the sum of the two different units.
Left: Entities stop sitting after playing the behavior for 18 frames - Right: Entities stop sitting after playing the behavior for 1s of the animation duration (ie 18 frames)
This trigger has no meaning as a starting trigger, as the behavior has not yet run.
Motion Time Trigger
The Motion Time Trigger enables to stop a motion Behavior (Motion Behavior , Locomotion Behavior, Synchronized Motion Behavior) when this Behavior has been played for a specific time. The time can be expressed in frames, seconds or percentage of the played Motion clip. The time corresponds to the sum of the three different units.
Left: Entities stop sitting after playing the animation for 18 frames - Right: Entities stop sitting after playing the animation for 5% of the animation duration (ie 18 frames)
This Trigger can be useful to stop a Motion Behavior when its animation has been played once (100%) or played for 5 seconds.
This trigger has no meaning as a starting trigger, as the behavior has not yet run.
Script Command Trigger
The Script Command Trigger enables to start or stop a Behavior when a MEL/Python function returns true. You can use the special tags #ps# and #pid# to use the Entity corresponding particle system name and particle id in your code.
Left: Entities sit when the sphere and the cube intersect - Right: Entities sit if placed in XZ
This Trigger is useful to extend the library of provided triggers with custom function. As almost everything in Maya is queryable with MEL/Python, it allows to create almost any test.
Physics Collision Trigger
The Physics Collision Trigger enables to start or stop a behavior when a collision with another physicalized entity or a Crowd Rigid Body occurs. The trigger only works when both entity are physicalized thanks to the Physicalize Behavior.
With such a configuration, entities only react when they're in collision with a green Rigid Body.
Boolean Trigger
The Boolean Trigger enables to start or stop a behavior always returning the same value (true or false).
Fade Trigger
The Fade Trigger enables to delay the perform of Triggers attached to a Behavior thanks to a ramp.
Result of the previous attached Polygon Zone Trigger will be spread on 10 frames.