Behavior Tree Stops Unexpectedly

kcclark23

New member
Hi,

I'm new to BD and I'm sure there are much better ways of doing what I want, but for my purposes this simple tree works okay, for about 5 minutes. I have some teams and I want them to seek resources that I have instantiating on the map. When the teams come into contact with one another, their highest priority should be to eliminate the other team which they do for about 5 minutes until they eventually stop moving, or just endlessly jitter around which is the case in the image I've attached.

I've tried probably a dozen different variations of very simple trees but they always tend to do the same thing. I assume they lose their target, but I find it odd that it works so seamlessly for a few minutes until it just doesn't. I've attached a couple images of what's going on. The tree that I posted shows that the Attack task is still being executed but also shows that it's complete. I've tried it with and without a Repeater which seems to change the way it executes but not the outcome. I'm also not fully confident with Conditional Aborts yet, so I've tried moving them around to see the outcome (as you can see, I have one on damn near every Composite node). I've debated re-scripting everything by hand or in Playmaker but I'd really rather not do that since everything I need is built into BD already. Any suggestions would be greatly appreciated.

Another random technical question. I want to make the tactical movements a bit more true to real life once I get all the other little technical stuff worked out. Is there a way that anyone knows of to get the agents to fire while in formation, fire while moving during "Marching Fire", and while bounding ("Leapfrog"), in that the rear portion of a fire-team provides covering fire while the forward team moves? I'm assuming I would have to code a lot of this myself, but I didn't know if there was an easy workaround.

Any help is greatly appreciated. Thanks!
 

Attachments

  • BD Stuck Tree.PNG
    BD Stuck Tree.PNG
    133.6 KB · Views: 13
  • BD Stuck GameObjects.PNG
    BD Stuck GameObjects.PNG
    392.2 KB · Views: 13
Your editor looks really odd - I would first reimport it just because it looks like it's missing the correct grid shader.

Is the tree in your screenshot active? It looks like it ended successfully. One way to determine why the tree is doing what it's doing is to enable logging on the behavior tree component - this should give you a better idea from tracing the logs what task caused the tree to end.

Looking at your tree though I would remove the Selector Evaluator. This task essentially replaces conditional aborts and is more of an advanced task.

Another random technical question. I want to make the tactical movements a bit more true to real life once I get all the other little technical stuff worked out. Is there a way that anyone knows of to get the agents to fire while in formation, fire while moving during "Marching Fire", and while bounding ("Leapfrog"), in that the rear portion of a fire-team provides covering fire while the forward team moves? I'm assuming I would have to code a lot of this myself, but I didn't know if there was an easy workaround.
Unfortunately there's not a straight forward workaround for this setup.
 
Gotcha, it's not terribly important, I just figured I'd see if there was a simple way.

As far as the tree, I rebuilt it from scratch in the same configuration without the Selector Evaluator and after re-importing everything. It seems to be returning Success based on the log but it still shows that it's running within the editor. I've tried placing a Repeater so that it would start over again after it returns a Success but it seems to get stuck at the Repeater.

It may be my ignorance of how the trees work and I apologize for all of the questions but I'm stuck. Thanks for all the help thus far.
 

Attachments

  • BD Success but not Repeating.PNG
    BD Success but not Repeating.PNG
    305.2 KB · Views: 5
  • BD Success but Active.PNG
    BD Success but Active.PNG
    330.4 KB · Views: 5
Is your repeater set to Repeat Forever? It also looks like you are getting a lot of errors - if you fix those does it work better?
 
I do have it set to repeat forever, which is why I'm confused. I tried setting it to some ambiguous values to see if it was just a bug but to no avail.

The errors are from a couple random placement and resource spawner scripts that I wrote. I cleared out my prefabs and I'm completely restructuring my code so it's throwing a NullReferenceException for a few different scripts every tick but it shouldn't have anything to do with the BD tree; at least not that I would think since none of my Tasks reference any of those particular missing GameObjects.

There's one thing that I thought might be effecting it but I would assume it would still track since it's searching for enemy Agents by tag. I wrote in a transform when the Agents 'die' so that they respawn on the grid-square that their team owns. Is it possible that when they transform, they're losing their target or tracking to their position prior to the transform and reporting success? I'm not sure if there's an issue with BD updating an Agents position following a transform but I figured it wasn't an issue until now.
 
Behavior Designer runs on the main thread so if you're getting errors that can definitely mess with the functionality. I would clear those errors up first and then see if that helps at all.
 
I cleared all the errors and let it run a few times to see if the outcome was different but it looks like it's doing the same thing. I did notice that it seems to be pushing and popping the attack task over and over again in a loop. I'm not sure why it's doing it but it explains why everything freezes if it's never pushing and popping new tasks. I appreciate all of the help thus far.
 

Attachments

  • BD Success but Active Looping.PNG
    BD Success but Active Looping.PNG
    256.5 KB · Views: 6
  • BD Success but Active2.PNG
    BD Success but Active2.PNG
    274 KB · Views: 6
Top