Hello again, sorry for asking more questions...
In my behavior tree I have a need for a lot of nodes like "do an action and wait for its effect to complete, or X seconds, whichever comes first". For now I do it like this :
The blue "wait until door is open" node essentially keeps Running until the door is effectively open. But this may take forever, especially if there is something in the way because my doors are physical, so in parallel there is a timer that returns failure after 2 seconds. Whichever stops Running first stops the whole sub-tree thanks for the Parallel Complete node. Don't mind the blue color, I just color any node that references another one so I remember who needs what.
This solution works but I find it a bit cumbersome and I would rather do it like this :
This decorator is supposed to return Running while the child is Running, or the status of the child if it's not, or Success or Failure (specified in the node) if the timer expires first.
It is cleaner and more intuitive but this "Time Limit" task does not work because it does not execute while the child task is running. I understand that this is probably by design so I thought of starting a coroutine in the OnStart () function to let the timer run in parallel but I don't know how to interrupt the child task when it expires. I've looked into the code of the other decorator tasks but that didn't help me much, all of them run only once their child has returned a result.
How could I write such a decorator task ?
Thanks !
PS : On a side note, I read somewhere that conditional tasks should never return Running because they're not doing anything, they're just checking data. I agree but on the other hand, I don't see the need for distinguishing actions and conditions since they both return a result. To me there should be only action nodes. Moreover, this particular task waits for something to happen, so although it's not doing anything on its own, it still needs to wait and not return a result right away.
In my behavior tree I have a need for a lot of nodes like "do an action and wait for its effect to complete, or X seconds, whichever comes first". For now I do it like this :
The blue "wait until door is open" node essentially keeps Running until the door is effectively open. But this may take forever, especially if there is something in the way because my doors are physical, so in parallel there is a timer that returns failure after 2 seconds. Whichever stops Running first stops the whole sub-tree thanks for the Parallel Complete node. Don't mind the blue color, I just color any node that references another one so I remember who needs what.
This solution works but I find it a bit cumbersome and I would rather do it like this :
This decorator is supposed to return Running while the child is Running, or the status of the child if it's not, or Success or Failure (specified in the node) if the timer expires first.
It is cleaner and more intuitive but this "Time Limit" task does not work because it does not execute while the child task is running. I understand that this is probably by design so I thought of starting a coroutine in the OnStart () function to let the timer run in parallel but I don't know how to interrupt the child task when it expires. I've looked into the code of the other decorator tasks but that didn't help me much, all of them run only once their child has returned a result.
How could I write such a decorator task ?
Thanks !
PS : On a side note, I read somewhere that conditional tasks should never return Running because they're not doing anything, they're just checking data. I agree but on the other hand, I don't see the need for distinguishing actions and conditions since they both return a result. To me there should be only action nodes. Moreover, this particular task waits for something to happen, so although it's not doing anything on its own, it still needs to wait and not return a result right away.