Other Scripts¶
Besides the main script and adapter scripts, there could be other scripts that are used in the behavior tree system.
At the moment there is only one such script called btEntityReference which is used to reference an entity from the world into the behavior tree and is currently can only be utilized by the Setter <set> node.
btEntityReference script¶
The script has only one property called Referred which you can use to refer to an entity from the world.
Usage¶
For example: name the entity <set DoorEntry=_ref> and attach btEntityReference script to it. Then set the Referred property of the script to the entity you want to refer to. When this node is activated in the behavior tree, it would set the value of the blackboard key DoorEntry to the entity reference from btEntityReference script and hence blackboard would refer to your entity.
Note that the reference would only be preserved in template if it points somewhere within the same template (i.e root of template contains both the entity with btEntityReference script and the entity that it refers to). This is a DBB limitation and while it could be adjusted in the future, it is still recommended that if your behaviors require static references to any entities in the world, to make corresponding sub-trees of behaviors attached to those entities (or the templates they are in) and then plug them into the behavior tree using Dynamic <dyn> nodes.
This way, you could have for example a behavior describing how to enter building through the door being defined under the building itself and when NPC needs to enter the building, their <dyn> node would refer to the building door entry and run the behavior subtree defined on it.