Debug logging of BehaviorTree component instance?

JasonT

Member
Hi I'm just wondering if there is a built-in way to have Debug.Log print the specific BehaviorTree name that the task throwing the error is on? As my project is growing it's getting harder to track down. I can edit the task OnStart to grab a reference to the BehaviorTree component but wondering if there's some other way.
 
Last edited:
Are you referring to when you log the tree within the behavior tree component? Or logging within your own task?
 
Well either way, I feel that I'm not using the Debug tools effectively. I have a dozen trees running, and I don't normally leave Log All task changes on every tree so I don't flood the console. So when a task throws an error, or a null exception, I have a hard time finding which Tree contains the Task that is causing the error. Once I know which tree it's very easy to find the task with the find tool. For my own Tasks, I've started to grab a reference to it's own behaviorTree so I can print it to the console with the error. Just wondering if I'm missing a better way, or if there is anyway to do this with the built-in tasks.
 
One way that you could accomplish this is to log the GameObject name when the object is null. You could also place the code that is causing exceptions within a try/catch block and then output the GameObject (or behavior tree) name.
 
yes that's what I've been doing with my own tasks and also editing some built-in tasks that I'm using. I just wondered if there was some other direct way to drill down to find the Behavior tree name when the error occurs the first time, maybe even through the profiler?
 
Besides logging if you place a breakpoint you can then inspect the Owner object to see what the behavior tree name is, but that's about the extent that I've been able to debug which tree is actually causing the error.
 
Top