Example behavior tree doesn't fully work

arenoo

Member
Hey, I don't know if it's only me in this whole world but in my case almost nothing from this asset works out of the box. The example behavior tree is barely functioning. Half of the branches simply do not work.

Can hear target? - doesn't work
Has taken damage? - doesn't work
Take cover? - doesn't work
...

Okay so I started debugging Has taken damage...

Lets see the main condition: if (m_DamageFrame >= Time.frameCount - 1). For optimization purposes I set the Behavior Designer update mode to every 0.2 seconds instead of every frame, so this condition would never work right? So I switched it to a simple boolean isDamaged that gets set true when OnHealthDamage event is triggered keeping in mind that OnUpdate gets called every 0.2 seconds as I'd set it to.
index.php

Instead it waits 0.2 seconds and gets called twice. As I couldn't figure out why it happens I just added a wanky solution to account for getting called twice. Now this task works as expected. Moving on in the behavior tree we have a branch that should make the agent start searching for the shooter.
1691593156050.png
Instead the agent just casually walks away. Note that the Possible Target field gets set correctly. And yes, the demo scene is working as expected. Please help I am going insane
 

Attachments

  • 1691592418066.png
    1691592418066.png
    73.7 KB · Views: 33
If the demo scene works correctly then it's something specific to your setup. Have you followed this video? It shows step by step on how you can get the tree working. I recommend following that video exactly as it is and if something is different take a step back to determine what is incorrect.


After you get everything working here you can then bring it into your own scene since you will be at a good starting point. Do not make any other changes (such as changing the tick rate) until you first get everything working. You can debug performance issues later.
 
My current scene is already built following that tutorial so I don't think the problem is there. What else could cause such behavior in case of reacting to getting damaged branch?
 
After the tutorial finished did it work? What changed since it was working?

It's really tough to say without playing with it and stepping through the code. I would first revert your optimizations so you can first get it working. From there if a task isn't behaving as you'd expect you should look at the variables being used by the task to see if they are correct. If they are then it's related to the logic of the task and is best solved with breakpoint debugging.
 
Ah, thanks for the details.

For something like this it's really hard to debug without stepping through the code. I would start with the Has Taken Damage task - that is just listening for an event so when the agent is shot you could set a breakpoint to see if the event is received from the task.
 
Turns out I had added a parallel node on top of the main execution branch and it had a wait node in it. That wait node was throttling the whole tree. thanks
 
Top