If
An If Operator (beOpAlternative) is used to select one connection among several connections and conditions.
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.
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.
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)
If / Else if | Configure en existing connection, by changing:
|
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