Task with no immediate return SUCCESS/FAILURE instantly returns SUCCESS
EnricoPietrocola opened this issue · comments
I am trying to create a Wait Task in order to quantize tasks in a sequence. If I put my return SUCCESS in a setInterval or async/await function, the task seem to immediately return SUCCESS instead of hanging the tree.
Is this a bug or am I doing something wrong?
That is not a bug and rather natural, I would say.
Usually you do a run of the BehaviorTree in fixed intervals and want to have the result immediately on which behavior your agent is right now. If you would introduce async code in there you would complicate the writing of the behaviors since you always have to worry about that and also would likely make everything a bit slower, because the code has to check more stuff. And you want everything to be fast. Doing a setInterval
would even put the JS runtime into another run-cycle, so there would be no way to figure out when the code has to return (and what it would return to).
I am not quite sure that I understand what you want to achieve. Can you alaborate what Wait Task in order to quantize tasks in a sequence
means for you?
Thanks for the explanation. What I am trying to obtain is a task that is executed in a period of time.
What I am trying to achieve now is a tasks that lasts for 1000ms, simply waiting, in a Videogame for example I would use this for humanization or reflex delays. After that I would try making tasks that do something for a period of time and stop when the task is over.
What I was expecting is that if a task didn't return anything, it would get stuck there, but this doesn't seem the case since my sequence is executing the second task anyways even without any form of return from the previous one
(p.s. Sorry, I've never used the issues section, I didn't mean to close :D )
I'm sorry, I just realized that all I had to do to get what I wanted was adding RUNNING and using this in my tasks, I should have read your documentation more thoroughly
After reading your further explanation, I just wanted to suggest using RUNNING
for that cases, so you are on the right track. Glad you found it yourself :-)
So, if that issue is resolved, you can close it now. Or is there something more unclear?
Absolutely all clear! Thank you very much