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.
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
Alternative Attributes of an If Operator
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). |
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:
An If Operator processing a "if ... else if ... else ..." selection