Property Mappings, Shared Behavior Trees and mappings in code

chaneynow

New member
Justin,

I'm running into a problem with trying to share External Behavior Trees. They act differently from Trees maintained within the component. If you have your Behavior Tree Component with External Behavior Tree connection on a gameobject within the character hierarchy other than the gameobject that contains the class where you have your properties (to be mapped), you get the following error message for each property you have mapped.

Error: Unable to find component on Behavior for property mapping with variable PlayerObj
UnityEngine.Debug:LogError(Object)
BehaviorDesigner.Runtime.SharedVariable`1:InitializePropertyMapping(BehaviorSource)
BehaviorDesigner.Runtime.JSONDeserialization:DeserializeSharedVariable(Dictionary`2, IVariableSource, Boolean, List`1)
BehaviorDesigner.Runtime.JSONDeserialization:DeserializeVariables(IVariableSource, Dictionary`2, List`1)
BehaviorDesigner.Runtime.JSONDeserialization:Load(TaskSerializationData, BehaviorSource)
BehaviorDesigner.Runtime.BehaviorSource:CheckForSerialization(Boolean, BehaviorSource)
BehaviorDesigner.Runtime.Behavior:CheckForSerialization()
BehaviorDesigner.Runtime.BehaviorManager:LoadBehavior(Behavior, GameObject, String, Transform)
BehaviorDesigner.Runtime.BehaviorManager:EnableBehavior(Behavior)
BehaviorDesigner.Runtime.Behavior:EnableBehavior()
BehaviorDesigner.Runtime.Behavior:Start()

This doesn't make sense given that I have the Behavior Tree properties all mapped to the correct class on the correct gameobject within the same character hierarchy. It seems to indicate that it's not a true variable mapping.....that the mapping still relies on the behavior tree component w/ external tree connection and the class containing the property be on the same gameobject. This is not the case if I am Not using an external behavior tree.

I have been trying to keep my Behavior Trees on separate gameobjects within the character hierarchy, separate from all of my controller classes because the Unity editor performance simply cannot handle the Behavior Tree and all of the stuff going on in the Inspector in all of those classes (Animator included) if you have that gameobject selected.

It seems that there should be some way to establish the variable/property mappings through code, perhaps using a C# Event system that exists outside of the behavior tree code. This would also eliminate the need to manually establish the property mappings.


Thanks
Allan
 
Last edited:

Justin

Administrator
Staff member
Can you post a screenshot of your Behavior Tree component with the mapped variable, and also the external behavior tree with the variable that should be overridden?
 

chaneynow

New member
The first pic shows an external tree being used in a behavior Tree component on the CombatTreeExtBehavior gameobject with all of the variables mapped to their corresponding properties in EnemyController.cs on the ClimberController gameobject.

The second pic shows the same tree on the CombatTree gameobject with all of the variables mapped to their corresponding properties in EnemyController.cs on the ClimberController gameobject but NOT using an external tree. To test, I simply Activate one gameobject and deactivate the other.

Both Trees run as expected but when using the activated CombatTreeExtBehavior (using External Behavior Tree) I get the errors which you can see in the console.log. There is one error message for each Property Mapping. You can see the first error message is referring to the first Property Mapping (PlayerObj).

External Tree Reduced.jpg
Non External Tree Reduced.jpg
 

Justin

Administrator
Staff member
Hmm, that looks like it should work. I'll try to repro it on my end and see what's happening.
 

chaneynow

New member
Thanks. In the mean time, I've created a task that I can place at the beginning of my trees to Register Events and thanks to FormationGroup.cs, I learned there is a OnBehaviorComplete override that appears to work for Unregistering Events.

This will allow me to get rid of most if not all of my Property Mappings.

Allan
 
Top