Behavior Tree Variables do not ever update / set initial value using property mapping

Overlogical

New member
Hello. I would like to set a variable inside my behavior tree to the value of another variable of the same type inside a monobehaviour script on the same gameObject using property mapping. I have set the property selection of the variable to the appropriate property in the script, but when starting the game, the variables inside the behavior tree remain at their default values. I have tried this with bool,float and int variables.

this is the property code:
public int testvar = 5;
public int Test { get{return testvar; } set { testvar = value; } }

After starting the game, the variable in the behavior tree remains at 0.

I am using version 1.7.2 of the behavior designer and version 2021.1.7f1 of Unity.

any help is greatly appreciated :)
 
For your shared variable did you set the property mapping value to your property?
 
If you set a breakpoint does it get called? Is that variable used in your tree?
 
Where should i set a breakpoint? on the property declaration? I am sure the script itself is being called. A break point in the start function gets called.

I have used the variable in an int comparison to see if it changes its value from one, but it did not.
 
Last edited:
Yes, on the property. Here's also a simple scene you can compare against which uses your property code and outputs the value of 5.
 

Attachments

  • IntMapping.unitypackage
    3.3 KB · Views: 2
It works on a normal gameobject, but when i try it on a prefab, the same error occurs. Is there something that needs to be done different with prefabs?
 
Ah, with prefabs you need to set the property mapping through script:

 
Top