Is it possible to return a value from an external BT?

scornflake

New member
I'm wanting to create a tree specifically to "choose the next target". I was thinking of putting this into an external BT so that I could use it in a few places... but I can't see a way to return a variable (such as a transform or gameobject) from a tree. Have I missed something? I don't really want to use globals since then the tree would have to know which global to put that value into - and that seems like the beginnings of the root of all evil ;-)
 
On the Behavior Tree Reference component you can specify any variables that you want overridden and it's here that you can also set the return status. If you ensure the variable has the same name and type on the Behavior Tree Reference task as it does on the external tree then that variable will be overridden and you can use it for a return status.
 
OK. I had a play and if I name the vars the same between trees, they are shared. I can also have different names, and assign values from one tree to another.

I didn't see anything relating to 'set the return status' tho. By that did you just mean that it's inferred? Any value set inside an external BT, that is either shared or 'mapped' (via behavior tree ref vars), acts like an 'out' var in c#? (i.e: it gets modified cos its shared)
 
Any value set inside an external BT, that is either shared or 'mapped' (via behavior tree ref vars), acts like an 'out' var in c#?
That's right. You won't get an actual return status from the external tree so you'll want to set a variable.
 
Top