Wait task not working for me

Archj

New member
Hi! Copy pasting my post on the Unity forums below:

Hello, new user of Behavior Designer here. Seems like a great tool. I'm working on porting my existing AI behavior into tree form.

I am curious about the Wait task, I can't get it to work. It doesn't seem to ever return success. Is it because I set my tree to repeat forever, or is it because of something else?

I basically have a selector with two child tasks, one conditional checking if a target is within distance, and a wait task set to 4 seconds. So if the distance check fails, the selector should still return true after 4 seconds, if I'm not mistaken. I've gone through the source code for the Wait task, and I see that OnStart() and OnUpdate() is called every frame, but OnPause(), where the elapsed time is advanced, never gets called. I'd love to know what I'm doing wrong! :)

Thanks!

Edit: I forgot to attach a screenshot of my current tree. This is my first tree, and while what I have is working (left branch is WIP), I'm really wondering if I'm doing anything "correctly" at all. Maybe there's a better way of doing it?
 

Attachments

  • first_tree.png
    first_tree.png
    87 KB · Views: 56
Last edited:

Justin

Administrator
Staff member
Your left branch doesn't end with any action tasks so that could cause problems, but my guess is that the parallel task is stopping because a task returned failure so that will prevent wait from running as well.

Take a look at these videos for how I've had success structuring my trees. You obviously don't need to follow this setup but it is a common behavior tree design:

 

Archj

New member
Thanks for the response! I modified my tree slightly (see image) and now it works. I will be looking more in depth at the video you posted to see if I can pick up some tips from that. Do you see any obvious issues with the current tree layout that can burn me later? Many thanks.
 

Attachments

  • second_tree.png
    second_tree.png
    103.9 KB · Views: 71

Justin

Administrator
Staff member
Glad you got it. I can't see anything obvious that's wrong with your tree but I do recommend using conditional aborts - they'll make your life a lot easier :)
 
Top