Create a Blackboard

We can add conditions and effects that control how the agents search the tree. Searching a tree will validate conditions against the agent's blackboard. Completing nodes will apply its effects to the agent's blackboard.

To start using conditions and effects in our trees we need to first create a blackboard and assign it to the tree asset (Assets->Create->BadgerHTN->Blackboard).

You can then start adding keys to your new blackboard that will show up when you select a node in the tree view.

Clicking a node in the tree view will show all blackboard keys. Clicking the plus icon in the conditions view will add "IsAlive" as a condition to the "Wander" node.

Updating the agent's "IsAlive" blackboard key can be done by adding it as an effect in the tree view or through code.

public class GameSystem : MonoBehaviour
{
    public void Update()
    {
        var blackboard = GetComponent<BadgerComponent>().Agent.Blackboard;
        blackboard.Set("IsAlive", true);
    }
}

Last updated