@@ -25,14 +25,25 @@ reconsider your decision to use them.
2525
2626## Pre conditions
2727
28- | Name | Description |
29- | -------------| ---------|
30- | ** _ skipIf** | Skip the execution of this Node, if the condition is true |
31- | ** _ failureIf** | Skip and return FAILURE, if the condition is true |
32- | ** _ successIf** | Skip and return SUCCESS, if the condition is true |
33- | ** _ while** | Same as _ skipIf, but may also interrupt a RUNNING Node if the condition becomes false. |
28+ | Name | Description | When Evaluated |
29+ | -------------| ---------| ----------------|
30+ | ** _ skipIf** | Skip the execution of this Node, if the condition is true | IDLE only (once) |
31+ | ** _ failureIf** | Skip and return FAILURE, if the condition is true | IDLE only (once) |
32+ | ** _ successIf** | Skip and return SUCCESS, if the condition is true | IDLE only (once) |
33+ | ** _ while** | If false when IDLE, skip. If false when RUNNING, halt the node and return SKIPPED. | IDLE and RUNNING (every tick) |
34+
35+ :::caution Important: One-time vs. Continuous Evaluation
36+ ** ` _skipIf ` , ` _failureIf ` , and ` _successIf ` are evaluated only once** when the node
37+ transitions from IDLE to another state. They are ** NOT re-evaluated** while the node
38+ is RUNNING.
39+
40+ Only ** ` _while ` ** is checked on every tick, including while the node is running.
41+
42+ If you need a condition to be re-evaluated on every tick, use the ` <Precondition> `
43+ decorator node with ` else="RUNNING" ` instead of these attributes.
44+ :::
3445
35- ::: note
46+ :::note Evaluation Order
3647Pre conditions are evaluated in this order: ` _failureIf ` -> ` _successIf ` -> ` _skipIf ` -> ` _while ` .
3748The first condition that is satisfied will determine the result.
3849:::
@@ -64,6 +75,35 @@ we can store a boolean in an entry called `door_closed`, the XML can be rewritte
6475<OpenDoor _skipIf =" !door_closed" />
6576```
6677
78+ ### Using ` <Precondition> ` for Per-Tick Evaluation
79+
80+ When you need a condition to be checked on ** every tick** (not just when the node starts),
81+ use the ` <Precondition> ` decorator node instead of inline attributes.
82+
83+ This is particularly useful in ** ReactiveSequence** or ** ReactiveFallback** where you want
84+ the condition to be re-evaluated each time the running child is ticked:
85+
86+ ``` xml
87+ <!-- This checks the condition on every tick -->
88+ <Precondition if =" battery_ok" else =" RUNNING" >
89+ <MoveToGoal />
90+ </Precondition >
91+ ```
92+
93+ With ` else="RUNNING" ` , if the condition becomes false while the child is running,
94+ the decorator returns RUNNING (keeping the tree alive) instead of immediately
95+ returning FAILURE or SKIPPED.
96+
97+ Compare this to the inline attribute:
98+
99+ ``` xml
100+ <!-- This checks the condition ONLY when MoveToGoal starts -->
101+ <MoveToGoal _successIf =" battery_ok" />
102+ ```
103+
104+ The inline ` _successIf ` is evaluated once when ` MoveToGoal ` transitions from IDLE.
105+ If ` battery_ok ` changes while ` MoveToGoal ` is RUNNING, the change is ignored.
106+
67107## Post conditions
68108
69109| Name | Description |
0 commit comments