Hi! I’m new to this package and to BTs in general. I’m implementing AI behaviour in my game, starting some with basic actions: “Patrol” (if a set of waypoints is provided), “Wander” (if no waypoints), “Detect” (look for a collider with tag in a given range) and “Flee” (if target spotted, run to a point a given distance in the direction away from the target.
I’m struggling a bit with some of the fundamentals of how Behaviour trees work:
- Is the whole tree “traversed” and evaluated each frame? I’m a bit stuck in an FSM mindset, and I can see BTs behave very differently.
- Actions have OnStart and OnUpdate - does the
OnStart()event get triggered every frame / every time the BT is “executed”? - When is the
OnUpdate()event triggered and what’s the recommended pattern for when to useOnStart(),OnUpdate(), andOnEnd()? - Is it “allowed” for an Action to update the Blackboard? For example, my “Detect” action might find a valid target, and I want that reflected in a Blackboard variable.
- If this is an appropriate thing to do, how do I reference the Blackboard from my Action script, in order to “set” a variable value? Does the action description pass a reference to the variable?
The logic I’m looking to implement in my simple tree is:
- Character starts either Patrolling or Wandering, depending on whether a set of waypoints is provided to the “Patrol” action.
- The Character is on the lookout for a collider with a tag defined in the “Detect” action. If it spots such a target, it’s set in the “Target” transform Blackboard variable.
- If a Target is set in the blackboard, the character stops patrolling or wandering and flees away from the target, using a distance/range defined in the “Flee” action, deriving a direction using the target and AI transforms to travel “away” from the target.
- When the character reaches the flee destination, it starts to Wander or Patrol again.
This is what I currently have:
I do worry that I’m not following the correct principles, and am trying to make a Finite State Machine!
Does this graph look “right”?
Many thanks in advance for any help you can give - apologies, I realise this is a probably a very basic “what is a Behaviour Tree” type question, and I’m asking for a lot of info in one post!

