Reply To: Re-evaluation of action node differs if it is in a subtree or not

NodeCanvas Forums Support Re-evaluation of action node differs if it is in a subtree or not Reply To: Re-evaluation of action node differs if it is in a subtree or not

#15589
Gavalakis
Keymaster

Hello there and thanks for the info.

Please let me clarify. The confusion comes specifically because of the “Dynamic” option and how that works differently for Action Task children versus Condition Task children. The behaviour of the Action Node you have here is the correct one. Action nodes do not re-evaluate per-frame even if their parent is set to be Dynamic. That is because Action nodes can also return Running and if they were to be re-evaluated, then they would not let the other nodes run at all. To demonstrate this please open up ActionNode.cs and comment out lines #38 and #40 as shown bellow.

Then create a simple behaviour tree like this:
DynamicRevaluate

When you enter play mode you will see that as soon as the left wait action is finished and execution moves to the second one, the first wait action is instantly “re-enabled” and interrupts the second one. Without the code change stated above (thus the original code), both wait action tasks execute normally one after the other, which is of course the correct behaviour. This is because Actions are handled differently than other nodes so that they can work correctly in the context of Dynamic parents (as shown in the original code)

SubTrees on the other hand do not make that distinction since they can contain any type of node and as such this special handling is not happening in the SubTree code. I hope all this was not very confusing 🙂

To summarize:
1) Your “RunningTask” I believe should be implemented as a Condition rather than an Action task. Doing this will allow it to work as you’d expect in the context of the Dynamic parent (and similar to how the SubTree behaviour works in your example BT).
2) I could add an option in the SubTree node to change the behaviour between Action-like or Condition-like.

Please let me know if the above clarify things up (or confuse things more) 🙂
Thanks!

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

Attachments:
  1. DynamicRevaluate.png