How to run a branch tree with a certain probability?

d.vasilev

New member
Hello!


There is a need to execute a branch of the tree with a certain probability. At the same time, it should interrupt other branches on the right according to the Lower Priority condition, if the probability allows the branch to execute.

The problem is that, in the current setup (as seen in the screenshot), this probability is recalculated constantly, and it may interrupt itself. I had a version where the first Sequence had a Lower Priority setting, and the second one was set to Self. In that case, the probability was calculated only once, and it could work, but in that version, the conditions in the second Sequence were not recalculated if the branch on the right (e.g., Wander) was active.

The instructions state that for the first node with conditions in the form of a sequence, you need to set the interruption mode to Lower Priority or Both; otherwise, it will not recalculate. Alright, but in my case, the probability does not work properly — it continues to be recalculated and may interrupt other tasks on the right (Seek, Start Stop Ability, etc.).

How would it be best to implement the execution of a branch based on a probability in my case?

Screenshot 2025-06-10 132328.pngScreenshot 2025-06-10 132329.png
 
If you don't want the branch to interrupt itself then a lower priority abort type is the correct way to go. If you want the probability to interrupt the tasks on the right then you will need to move the branch to the left so it can always reevaluate. I recommend taking a look at the Ultimate Character Controller sample tree as you can likely use similar mechanics:

 
Good afternoon! I watched your video, and I still don’t quite understand how to implement this in my case. It seems I wasn't able to properly convey my idea to you. Therefore, here's a new screenshot with the full scheme.

In my concept, the branch with the bot's attack on another player is the most prioritized, and it is located on the left. At the same time, it has the type Lower Priority. In this branch, the first node contains a condition in the form of a sequence. It must be calculated ONLY once and only when this branch is inactive. That’s why I set its interruption type to Self. When this sequence is fully processed, the branch continues, and it has its own interruption logic from there.

For conditions assembled as a sequence, the interruption type Self is required due to the probability calculation for the branch to start. If this is changed to Both or Lower Priority as the instruction suggests, then this sequence of conditions will immediately interrupt the branch, because the next probability calculation is unlikely to be successful.

I have two questions:

  1. Why is the use of Self for conditions in the form of a composite restricted? Why can it only be used for Low Priority and Both, and not for Self? I would like Self to also check these conditions. For me, it’s strange that Self doesn’t work.
  2. If it’s not planned to address this situation, how can this be implemented in a different way?
Снимок экрана 2025-06-14 074233.png
 
@d.vasilev Hi, I'm having a hard time following the whole thing, but I do wish to say that I don't see any issue with the Self conditional abort - on my side it works as expected when used on a simple Sequence with conditional tasks underneath. I can offer you one screenshare for free if you're interested, that way we could make sure we are on the same page.
 
Back
Top