Reply To: Code that should always run

NodeCanvas Forums General Discussion Code that should always run Reply To: Code that should always run

#9048
Gavalakis
Keymaster

Hello,

This is probably the most asked question as far as BT pattern goes 🙂
So, the way to run parallel actions is of course to use the Parallel node. If you want to run an action while a condition is true this can also be achieved with a Parallel + Repeater or just a Repeater. Depends.

I’ve attached 3 images:

1. The Parallel node ticks both childs silumtaneusly on each Tick. Because it is set to First Failure and it is Dynamic, if the condition returns Failure, the rest of the Running children (in this case the Repeater) will be interrupted. But while the condition is true, the Repeater will keep ticking the Action ‘Forever’.

2. Another solution for a while-do loop is this use of a “Repeater Until Failure” prety much self explanatory 🙂

3. Just a idea of how you could do a go to last seen position with the available tasks. It might not be exactly what you want, but works fine :). (remember that an Accessor is practicaly the same as a Sequencer with a condition as a first child). The 2nd Accessor does not need to be Dynamic, or else it will immediately be interrupted due to the hadLost becoming false.
If both of these child nodes return Failure, it either means that the agent can’t go to that position or never had a LOS with the sphere (target). It will even work dynamicaly meaning that the agent will not need to come to a full stop.

As a final word. If you want to run actions in parallel, the Parallel Composite node is what you need. I just expanded on that on my eplanation so that I provide more insightfull information.

Let me know if you have any question
Cheers!

Join us on Discord: https://discord.gg/97q2Rjh