Restart a sequence when an event is received

FredL

New member
In my test tree, I have an Idle task which runs until an event is received, which then runs the Left and Right actions in sequence (with a lower priority conditional abort):

1704906580892.png

In addition to this functionality, how would I be able to restart the Left/Right action sequence from the beginning when the event is received? So the process would look like this:
  1. The Behavior Tree is initialised, and the Idle task runs.
  2. Event is received, and the Left Action, followed by the Right Action runs.
  3. Before the Right Action has finished, the Event is received again.
  4. The sequence would then go back to the beginning and restart playing the Left Action.
  5. Assuming no more Events are received, the tree would then play Idle.
I tried changing the conditional abort on the sequence to "Self" but that seemed to prevent the sequence from playing at all.
 
This situation will require you to use the interrupt/perform interruption tasks instead of conditional aborts. Conditional aborts work great for most use cases, but in situations like this they aren't able to handle every situation.
 
Many thanks, I got there in the end with a interrupt/perform interruption task and the help of a variable behind the scenes:

1705080706495.png

It's a bit messy while I'm still learning - on first run the "Has the Event been clicked?" conditional returns false/failure, and so the Idle task runs. When the Event is generated, a global variable is set to allow the "Has the Event been clicked?" conditional to return true/success and the Left/Right actions to run until the "Reset the Event flag" task resets the global variable to zero, going back to Idle.

I'd rather not use a hidden variable and rely just on the event, but I couldn't work it out.
 
Top