Task to go to another task?

abc123

Member
Hello, my tree reevaluates each frame and all tasks return failure or success. I'd like to create a task, which tells behavior tree to instantly jump to another (selected) task. For example, if Use Melee returns success, I want to skip everything else and run Send Input. Any tips on writing a Go To task?

image.png
 
Last edited:
Moving directly from one task to another isn't possible with behavior trees. You can use the Behavior Tree Reference task if you want to include a common set of tasks, but jumping tasks is more along the lines of a state machine compared to behavior trees. If you want to move to that rightmost task you should setup the conditions so it falls through to that task by the regular conditions.
 
Thanks for the answer, that's a pity. I thought its possible to interrupt current child under the target task's parent, and change it's currentChildIndex to the index of target task. But thinking about this, now I see where it gets tricky, as we need to forcibly start the whole branches, which may conflict with current conditions. Well, seems like it was a bad idea...

So I made it the other way, and it doesn't work. As you can see, the main Continued Sequence should be interrupted by Use Melee, but it still runs remaining branches. This screenshot was taken when I stand in front of AI, and he uses melee each frame. So, I expect the right side should not be green?

111.PNG

PS Perform Interruption and Interrupt tasks are, of course, linked.

Continued Sequence is my custom class, which runs all the children no matter what and returns Success. What am I missing?

222.PNG
 
Last edited:
Have you looked at using conditional aborts? With this you could have a top level conditional task reevaluate if the tree should continue along that branch, and as soon as it returns failure it could drop off to the rightmost task. I think that it would work out perfectly for this situation and you won't need to use the interrupt set of tasks.

If it helps I created a pretty complex behavior tree for our character controller integration. I went into detail for how it works on this page and you should be able to get some ideas from it on how to structure your current tree.
 
Have you looked at using conditional aborts? With this you could have a top level conditional task reevaluate if the tree should continue along that branch, and as soon as it returns failure it could drop off to the rightmost task. I think that it would work out perfectly for this situation and you won't need to use the interrupt set of tasks.

If it helps I created a pretty complex behavior tree for our character controller integration. I went into detail for how it works on this page and you should be able to get some ideas from it on how to structure your current tree.
I know about conditional aborts, may be I will use them. But for now I want to solve the current problem. I would like to place more Perform Interrupts in this tree, so can you please explain why the Interrupt doesn't work in my case?
 
It's extremely tough to say why it's not working in that particular use case by a screenshot. If you can send me a smaller repro scene I can take a look. But my guess is that the task is being interrupted and then the next frame it starts up again.
 
It's extremely tough to say why it's not working in that particular use case by a screenshot. If you can send me a smaller repro scene I can take a look. But my guess is that the task is being interrupted and then the next frame it starts up again.
Unfortunately, I can't. Yes, the task restarts each frame, but screenshot is from situation where it should be interrupted each frame as well. Thanks for the answers, I will try to find where the problem is.
 
Top