13. Make a Decorator

13. Make a Decorator

On this page

Decorators, also known as conditionals in other Behavior Tree systems, are attached to either a Composite or a Task node and define whether or not a branch in the tree, or a single node, can be executed.

This Decorator is going to stop execution of the Rapid Move To branch of the Behavior Tree once the AI's Pawn is close enough to its target. While this could be handled in the Rapid Move To Task or by just using a Move To Task, this decorator can take in any Actor and can block execution of any branch. This makes it reusable in a number of situations.


  1. Open the FollowerBT Behavior Tree by Double-clicking it in the Content Browser.

  2. Click New Decorator button.

    It will create in the same folder as the Behavior Tree.

  3. Rename it in the Content Browser to "CloseEnough".

  4. The editor should have already opened it for editing, but if not, Double-click it in the Content Browser.

  5. In the Functions section of the My Blueprint Tab, "Override" PerformConditionCheck.


  6. Create the following graph in that new function:

    Copy Example

    Click the image to expand it, or click here to open it in the window.


    The variable names, types, and values for this Blueprint:

    Variable Name








    0.0 - However, this variable has its "Editable" flag set to True so you can change it, per instance, on the Behavior Tree.



    None - However, this variable has its "Editable" flag set to True so you can change it, per instance, on the Behavior Tree.

    As this is a Function Graph, if you use the Code Snippet from the graph image above, you will only get the center portion of the graph, and the beginning and end nodes will not be connected. Just wire those connects as the image shows, and it will work just fine.

  7. Event Receive Condition Check is the event sent to this Blueprint when the Behavior Tree hits a node with this condition on it.

  8. Once again, store the AI Controller so we can reference it later easily.

  9. Get the Actor we want to follow (the Player Pawn).

  10. Get the distance between that Actor and the AI Pawn.

  11. If distance is greater than a configurable amount, then the condition returns True. If not, then it returns False and blocks execution of the portion of the Behavior tree it is on.

This will make it so the Behavior Tree is not constantly cycling to the RapidMoveTo and back out again. Basically, if they caught up to the player, then stop.

Select Skin

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback