Back again another question about ActionTask. I noticed that when a branch is interrupted or reset, OnReset is invoked on the ActionNode of that branch, which in turn calls action.EndAction(null) on the task, as shown in the following code, EndAction(null) sets the status of the task to Failure.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
///Ends the action either in success or failure. Ending with null means that it's a cancel/interrupt.
///Null is used by the external system. You should use true or false when calling EndAction within it.
This is mostly fine but in our game, we implemented some interruptable idle behavior which plays some cycle animation and audio on a character when the player is not interacting. When the player interacts, idle behavior gets interrupted and we branch to some other logic. We want to go back to idle once the branched behavior finishes. However since the status is set to failure when interrupted, it won’t resume/restart when we get back to the idle behavior again.
This will set the task status to Resting instead of Failure upon Reset, making it possible to re-run the task after interruption.
My question is, does this introduce any side effects? Why did you replace it with the following statement? status = success == true? Status.Success : Status.Failure;
Thanks for the details. To be completely honest, I can’t recall right now why I replaced the original, as it seems to be more correct.
I can’t foresee any side effects of turning back on the original. I also did quite a few tests with the original line of code in both BTs as well as FSMs, with various designs and everything seems to work fine. I will keep it for while and see if some issue pops up, even though I really doubt and if so, make the change permanent.