Fallbacks
This family of nodes are known as "Selector" or "Priority" in other frameworks.
Their purpose is to try different strategies, until we find one that "works".
Currently the framework provides two kinds of nodes:
- Fallback
- ReactiveFallback
They share the following rules:
Before ticking the first child, the node status becomes RUNNING.
If a child returns FAILURE, the fallback ticks the next child.
If the last child returns FAILURE too, all the children are halted and the fallback returns FAILURE.
If a child returns SUCCESS, it stops and returns SUCCESS. All the children are halted.
To understand how the two ControlNodes differ, refer to the following table:
Type of ControlNode | Child returns RUNNING |
---|---|
Fallback | Tick again |
ReactiveFallback | Restart |
"Restart" means that the entire fallback is restarted from the first child of the list.
"Tick again" means that the next time the fallback is ticked, the same child is ticked again. Previous siblings, which returned FAILURE already, are not ticked again.
Fallback
In this example, we try different strategies to open the door. Check first (and once) if the door is open.
ReactiveFallback
This ControlNode is used when we want to interrupt an asynchronous child if one of the previous Conditions changes its state from FAILURE to SUCCESS.
In the following example, the character will sleep up to 8 hours. If he/she has fully rested, then the node areYouRested?
will return SUCCESS and the asynchronous nodes Timeout (8 hrs)
and Sleep
will be interrupted.