BD Pro CanDetectObject/Seek Issue

jkaczmar

Member
I recently pulled a Behavior Tree tied to an NPC directly out into a Subtree. As soon as I do that, it loses its ability to use CanDetectObject. I'm using a Target variable that I populate with Player which I can confirm does show up in the inspector in both cases during runtime. However, the CanDetectObject always fails when the tree is referenced as a subtree and always works when the tree is tied directly to the NPC. Likewise, Seek can't track the Player even though Target is populated with the Player prefab.

Other code that relies on that Target variable = Player seem to work. For example, UCC isAlive checks on Target = Player and passes as expected.

The fact that the correct value shows up in both the Unity inspector as well as the variable section in the Subtree when I watch it during runtime would seem to indicate that I've set things up right. However, perhaps there is a nuance for setting up variables during runtime that I am missing? I've read through all the documentation and the samples already to no avail.

Also, is there a way to move subtree code back into the NPC once I've moved it out?
 
I figured it out. Even though the Target = Player was showing up in both the Main Tree on the character and the associated Subtree it wasn't registering until I clicked Variable override on the subtree. Nothing changed visually, but this was enough for the subtree to pick up the correct value at Runtime.
 
I have another related question to this that might be actually be a bug or require additonal documentation. I've been able to get variables to pass from a primary tree to a referenced subtree. For example Target = Player as described above now works. However, if you override one variable (in my case Target) it seems like all the other overrides become active. In this case, SightDistance for CanDetectObject shows up in the override list along with all the other subtree variables. Even though I don't change it, CanDetectObject is likely using 0 as the sight distance which obviously doesn't work very well as it effectively makes the NPC blind. If I hard code this number as 20 rather than using a variable, it immediately works in the subtree and the NPC can find the Player.

However, if I inspect the variables in the hierarchy window, my Sight Distance is still set to 20 in all cases which is misleading. I think overrides either need to be handled differently or additional documentation needs to be provided to outline how they work. My preference would be that changing one override doesn't effectively cause an override for all the other variables. Doing it that way would force you to override everything even if you only want to pass in a single overriden variable.

I'm not sure if this issue is related just to Senses or if it is a broader issue.
 
Can you try version 2.0.11 just to make sure we're looking at the same thing? I just assigned an override to a subtree with multiple variables and the inspector didn't change for any of the other variables. If it still does it in 2.0.11 can you record a video so I can get a better idea?
 
I updated to the new version, but I've since adjusted my code to workaround the issue by putting everything in the main behavior tree. Likewise, the other issue relating to A*/Navmesh. However, I'll block off some time at the end of the week to recreate a couple quick test scenarios to see if they still persist. Even if they do, lower priority for most of the community as they both have effective workarounds. I'll let you know either way.
 
Back
Top