Problems with Variable Mapping

qstorm32

New member
I’m having trouble with Variable Mapping. The first issue occurred with Unity 2020.1.17f1, The first and second issues occur with Unity 2020.2.6f1

Issue 1:
Without a Behavior Manager attached to any GameObject in the scene, within a Task I could Get the output of a Monobehavior property, but I could not set it. It works when a Behavior Manager is attached. I found the answer in a previous post ([Bug][Unity 2020.1.4f1][BD 1.6.7] Variable Mapping not working correctly). If this how it should work I would suggest noting it more prominently in the documentation.

Issue 2:
Now when I create a variable mapping I get an error (“Unable to find component on X_Behavior for property mapping with variable Y). This happens when I use my own project and when I use the source code in a fresh project.

Variable mapping works fine when
- The object is not a prefab
- The instance of the prefab is set in the inspector. However, the problem will arise again if the instance is reverted to the prefab.
- If the mapping is set in the prefab behavior tree editor when the Monobehavior component that contains the property is attached to the same GameObject as the Behavior Tree.

At the moment my current workaround is to set the Behavior Tree preferences so that I can edit the mapping in the instance of the prefab and then apply an override. However, if I then revert the instance it reverts to the previous Behavior Tree and produces the same error. This may be just how Unity works with prefabs, I’m not sure.

Thanks in advance for your help.
 
Without a Behavior Manager attached to any GameObject in the scene, within a Task I could Get the output of a Monobehavior property, but I could not set it. It works when a Behavior Manager is attached. I found the answer in a previous post ([Bug][Unity 2020.1.4f1][BD 1.6.7] Variable Mapping not working correctly). If this how it should work I would suggest noting it more prominently in the documentation.
So the Behavior Manager is spawning after the behavior tree component is run? Or are you starting things manually? If you can list the steps to reproduce from a fresh project I can take a look.

At the moment my current workaround is to set the Behavior Tree preferences so that I can edit the mapping in the instance of the prefab and then apply an override. However, if I then revert the instance it reverts to the previous Behavior Tree and produces the same error. This may be just how Unity works with prefabs, I’m not sure
That is how it works with prefabs. The prefab is a project level asset and you'll need to point to the scene instance for the mapping to work.
 
Thanks for such a quick reply! All of these issues were resolved with a better understanding of prefabs.
 
Top