Toggling behavior on Can See Object and Cannot

subliminalman

New member
So I'm trying to wrap my head around the concepts of the Behavior Tree and some of them aren't fully sticking yet.

The basic behavior I'm trying to do is to chase the player if they're within a smaller vision cone, log to the console if they're in a larger vision cone, and do nothing if in neither.

It currently stays at the Seek function once it gets to that part of the tree even if I leave line of sight. Is this because Seek doesn't return success unless it HasArrived?

I've watched through all of the tutorials and checked the video recreating the Hollow Knight boss but currently behavior trees are not feeling very intuitive in my mind at the moment. Any help would be appreciated.

behavior.png
 

Justin

Administrator
Staff member
The Selector to the left of the idle task with the Lower Priority conditional abort is unnecessary as that conditional abort won't be triggering anything new.

Should the larger or the smaller Can See Object check have priority? Seek will run until it has arrived, but you can abort it using conditional aborts (though in your case there isn't anything that can abort the task so you may need to flip the Can See object branches).
 

subliminalman

New member
So I updated to this last night before you messaged. It kinda works but it throws a lot of false failures in that while I'm in a sight area it will stutter between on and off while moving in it when I would expect it to stay true.

I feel like this is also wrong, especially based on your description above but when I tried to update to what I thought you were saying it would stay in the Idle position.


I've attached my current version and a diagram of the setup I'm trying for.
 

Attachments

  • diagram.png
    diagram.png
    21.1 KB · Views: 6
  • diagram2.png
    diagram2.png
    88.7 KB · Views: 6

subliminalman

New member
Also here is my interpretation of what you were saying. It will not exit the Idle state unless I'm initially in the cone but once I exit it will stay stuck in the Idle state.
 

Attachments

  • diagram3.png
    diagram3.png
    82.5 KB · Views: 4

subliminalman

New member
Ok so I figured out why the InSight was causing flickering and that was due to an object from the observer being in line of sight so that's on me.

I updated the tree to look like this and it works but it feels a bit off still in terms of best practice. Checking IsSeen three times seems a bit wrong to me to get to Idle. I tried to store the variables and use CheckGameObject but it would cause a stall at Idle still.

Is there a better way to do this that I'm just not seeing?
 

Attachments

  • diagram4.png
    diagram4.png
    82.2 KB · Views: 8

subliminalman

New member
I think I got it? Apologies on all of the replies, I'm still kinda stumbling my way through and hopefully my stumbles help enlighten others who have the same pain points.


So this feels a bit more like what the intended way of creating a behavior tree. If there's a better practice please let me know.
 

Attachments

  • diagram5.png
    diagram5.png
    77.3 KB · Views: 16

Justin

Administrator
Staff member
Glad you are making progress! Yes, your last solution is exactly what I would do :) Hopefully it'll be easier to add new functionality from here on out!
 
Top