Variable Doesn't Exist

willij

New member
I have a base tree that references another tree using my slightly modified behavior tree reference task. I'm trying to set a variable that shows up in the referenced behavior tree but it gives a "[Variable] doesn't exist" error. How can I use behaviorTree.SetVariableValue("[Variable Name]", [value]); with a tree that has been added onto the base tree (without having to add the variable to the base tree)?

Thanks
 
After the external tree has been consumed by the parent tree the variables will float up to the base tree. This will then allow you to do a SetVariableValue on the base tree. If you want to do a SetVariableValue before the external tree is consumed you'll need to call it on the external tree.
 
What do you mean by consumed? The variable I want shows up in the variable list in the behavior designer script that's attached to the game object at least. I'm calling it long after the behavior is created.
 
If it's showing up in the variable list then the variable should be there. Here's a quick test showing what you are trying to do.
 

Attachments

  • SetVariableValue.unitypackage
    4 KB · Views: 7
I can set the variable just fine on objects that use the external tree as the base tree. But with this object, if I get a list of all the variables on it and print it out, it only shows the variables on the base tree, not the external tree even if it's showing up on the list.
 
Top