If

An If Operator (beOpAlternative) is used to select one connection among several connections and conditions.

An If Operator item in  the Behavior Editor with two conditions and a default connection

Indeed, each connection is allocated a Trigger (shown by a bubble on the link) and an evaluation order (shown by the index next to the Trigger). When the Alternative Operator is evaluated, the first Trigger is evaluated: if true, the related connection is selected, otherwise the next Trigger is evaluated and so on …

If all Triggers are false (e.g. no connection has been selected), the default connection (the link without bubble) is then selected. If no default connection is set, the Alternative Operator is blocking.

Each connections, except the default one, can be switched off by clicking on the arrow of the link.

Creation

  • Behavior Editor / Behavior Library: 
  • Golaem Menu: Crowd Behaviors / Operators / CrowdBeOp Alternative Node
  • MEL command: glmCrowdBeOpAlternativeCmd;

Configuration

Using the Behavior Editor

In the Behavior Editor, if the If Operator is not followed by a default connection, the next link drawn will define the default connection.

If Operator with a single default connection

When a default connection is already in place, every future link drawn will define another connection, with a True Trigger by default, preserving the previous order. This trigger will be used to make a "if (trigger) then… else …" statement.

If Operator with a previous default connection and a condition connection

Tip: If a Trigger is set as a condition, select it by clicking on the bubble of the related connection.

Using the Attribute Editor (Alternative Attributes)

Alternative Attributes of an If Operator
If / Else if Configure en existing connection, by changing:
  • The related condition, e.g. the Trigger to evaluate in order to select the connection (click on  to select this Trigger in Maya, click on  to open this Trigger in the Trigger Editor).
  • The target behavior, e.g. the Behavior to process if the connection is selected (this Behavior must be a child of the parent Behavior Container). Selecting the "no behavior" option removes the connection and deletes the related entry in the Conditions Attributes.
When several connections are establish, the labels "if" / "else if" define the evaluation order.
Add

Create a new connection between the If Operator and a given Behavior (this Behavior must be a child of the parent Behavior Container). A new entry "If" or "Else if" is then added in the Alternative Attributes, allowing to configure the condition associated to the connection (a True Trigger is set by default).

Else Select the Behavior targeted by default connection (e.g. the Behavior to process by default if all conditions are false).

Example

The following example describes an alternative selection between 3 Motion Behaviors (with  condition Triggers set up as shown in the Alternative Attributes description). When the If Operator is reached, the selection is preformed the following way:

  • First check if the entity is detected in nice zone : if so, then entity plays a cool idle animation
  • Otherwise, check if entity is detected in unpleasant zone: if so, then entity plays an angry idle animation
  • Otherwise, entity plays a neutral idle animation by default
An If Operator processing a "if ... else if ... else ..." selection