Skiping a leaf execution based on a condition


Is it possible to skip a leaf (programmatically, not using Atom UI) based on a certain condition during run time? Is using Switch the only option?


A switch is the best option for skipping a behavior like this, especially if you wanted to do so based on particular conditions.

As an example, if you had three behaviors (A, B, and C) and during one a particular condition you wanted to play all three in a row (A -> B -> C) but, under any other condition, you wanted to play just A followed by C ( A -> C) you could create a behavior tree that looks like this:

1 Like

Hello John,

Thank you for your answer. Unfortunately, I was trying to avoid using Switch because I think it is a kind of an overkill for skipping a leaf (ExecuteScript). I guess I will use if statement and force the leaf succeed when the leaf need to be skipped.


@Radim Depending on what you are trying to achieve with your skill, there are a few other options besides the recommended Switch example above:

  • SucceedOnCondition decorator will force the behavior it decorates to succeed if it meets the condition you specify.
  • TimeoutSucceed decorator will force the behavior it decorates to succeed after a define period of time.
  • If statements within your ExecuteScript

We do recommend using the Switches as it can be easier to debug, but we recognize this may not apply to your situation