How to debug debugging issues with external tree?

lorewap3

New member
No, that's not a typo. Even though I have the GO with the Behavior Tree component selected, I can see the tree in the behavior editor, and it even says the "GameObject Name (Editing External Behavior)" which usually means everything is good. But I'm not seeing any node highlighting when the tree runs. It's running, as I'm getting no errors and I can see the character moving intelligently. But I can't see what nodes are currently active and what task is currently running.

I'm using 2021.3.4f1 and recently migrated my project over from 2020. I mention that as this is the first time getting my behavior trees running again after the upgrade. I also had issues with copying the external trees over from the old project to the new. I kept getting a "no root node found" even when an external behavior was set (and it opened for editing when I clicked Open in the Behavior Tree component). Anyway, long story short recreating the tree manually and saving it out seemed to work. But it was a pain. It seemed to keep trying to use its internal tree even after the external one was set. I spent an hour banging my head on my desk before I just unset the external behavior and revealed the internal nodes within. It would be nice to know more specifics on when it tries to use its internal and when it'll use external. It did not seem to want to use the external if I had anything in the internal. So much so that it was easier to just delete the component and re-add it just to remove it's internal graph. I ran into a situation where I tried to delete all the internal nodes thinking "well now it will have no choice but to use the external", but I couldn't delete the Entry node. So I just re-added the component. Anyway, I digress, but it'd be great to be able to consistently predict when it will and won't use the external tree.

My apologies, that was a long tangent, but I wanted to mention it. Back on the main topic, my questions remains... how do I debug the debugging and figure out why I'm not seeing the active tree branch and tasks light up in green?

Thanks!
Will
 
First off are you running the latest version of Behavior Designer?

If an external tree is set the old internal tree is no longer kept. When the external tree is referenced then that tree will be loaded all of the time. If you're not running the latest I recommend first doing that, and if that doesn't work you could enable logging on the behavior tree component to see what it is loading.
 
Thanks for your quick reply Justin. I apologize for now providing version info that should've been a given. Here's a better presentation:

1) Unity 2020 LTS was working version. Behavior Designer 1.7.3 (July 5, 2022) running there.
2) Upgraded project to Unity 2021 LTS.
3) Initially copied BD over but in trying to debug the issues I opted to try a fresh install. As I prefer source code in general and having to make adjustments to other assets like Odin, Astar, etc, I opted to download & install the source. So I obtained/installed the BD runtime source from the opsive website (https://opsive.com/downloads/?pid=803) and installed that. I didn't check the version although I assume it's the latest.
4) Everything works as expected except for the nodes highlighting when they are active. I enabled the logging as you suggested and verified there as well. Here's a screenshot that shows just about everything:

1658251023229.png

As you can see from above:
a) Log messages are showing task changes
b) The GameObject containing the BehaviorTree component is selected (I clicked Open on it just in case to be sure the BehaviorDesigner editor was focused on it)
c) The nodes on the tree are not highlighting according to the current active task.

You will notice another embedded external tree within that tree. One thing I noticed was that in my previous project I remember the editor would automatically expand those external trees and embed them into this one. Not sure if that was changed in a newer version or not or if that is a clue to the source of the bug.

Thanks Justin!
Will
 
This is going to sound stupid, but are you sure that's the tree that is actively running? Also, was this a direct result of updating Unity? Have you been running version 1.7.3 with it working?

Beyond that are you able to repro the problem within a fresh project with a small external tree so I can better debug?
 
This is going to sound stupid, but are you sure that's the tree that is actively running? Also, was this a direct result of updating Unity? Have you been running version 1.7.3 with it working?

That's a very valid question. I'm 99% sure, but then I thought I was sure before when it seemed as if it was executing the internal underlying tree even though I had an external set (yes I know you said external overwrites internal but that's not what I observed before. But to the question, I'm 99% sure because all other trees are disabled in the screen. But on top of that, I make sure to click the 'Open' button on the Behavior Tree component itself on the GameObject to be sure.


Here's a screenshot of it working in Unity 2020 LTS:
1658352643363.png
The TinyChev_AI GameObject is selected. I clicked Open on the component, and voila I see the debugging.

Here's filtering all GO in scene to those with BehaviorTrees. As you can see the rest are disabled.
1658352718816.png

And Again in Unity 2021 LTS:
1658352925392.png
You can see in the hierarchy I've searched for BehaviorTree and there's only one GO enabled with one.


I don't honestly know if it's because of Unity 2021 or not Justin. It might be, it might not be. I could create a test project and try to do a minimal tree and see if the issue persists, but I doubt it would. I have no doubt you've tested the baseline functionality on 2021 already. And there's alot of tasks tied to alot of components and some from 3rd parties.

I guess what I'm saying is I'd honestly rather learn how to debug these issues myself than have to create a test project and send it over every time. I'm familiar with editor scripting and have built a number of custom tools so I can step-debug it to figure it out. However, while I have the runtime source I think the editor source is still closed as I only have the dll?

There's gotta be some way I can at least try to figure this out myself rather than have to pitch it over the wall everytime. Settings, anything. I'll look through the asset files themselves. I just want some sort of ability to debug this on my own.

Thanks,
Will
 
Hey Justin, I encountered something I didn't expect. I had the same issue with a brand new project. Here's the steps I took:

1) Create new Unity 2021.3.4.f1 project using the 2D URP template (yes I'll admit that's a weird choice but I'm using URP so wanted to test)
2) Imported BehaviorDesigner as well as the 3 addon packs. I installed them all from the package manager.
3) Opened the scene inside the 'Behavior Designer Tactical' pack.

Here's a screenshot of it in action. The game is playing, but there's no highlighting of active nodes on the right.
1658356504309.png

Guess I can provide a test project after all if you need it! lol. I will try as well with the latest update to 2021 that just came out (Unity 2021.3.6f) and will reply here if I encounter anything different.

I'm assuming the URP is not compatible with the ship materials which is why they're magenta, but that's fine. Maybe URP is messing up the debug drawing? Curious to know what you think!

Thanks!
Will
 
I guess what I'm saying is I'd honestly rather learn how to debug these issues myself than have to create a test project and send it over every time. I'm familiar with editor scripting and have built a number of custom tools so I can step-debug it to figure it out. However, while I have the runtime source I think the editor source is still closed as I only have the dll?
Yeah, I understand. The trouble is that I am not sure what would cause this would setting breakpoints in different locations. I haven't seen this occur before and it does sound editor related but I'm not completely sure until I can dig into it.

Guess I can provide a test project after all if you need it! lol. I will try as well with the latest update to 2021 that just came out (Unity 2021.3.6f) and will reply here if I encounter anything different.
It looks like the attack tree is enabled in the scene and during this execution the enemies don't move so I don't expect the Enemy Group tree to be active. If you change the selection to ambush does the tree light up?
 
Top