11. Make a Service

Step 11. Make a Service

On this page

Services attach to Composite nodes, and will execute at their defined frequency as long as their branch is being executed. These are often used to make checks and to update the Blackboard. These take the place of traditional Parallel nodes in other Behavior Tree systems

In this case, the service is going to look for any Pawn that is not an AI Character, then set the TargetToFollow and TargetLocation Blackboard keys.


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

  2. Click New Service button.

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

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

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

  5. Create the following graph:

    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


    Default Value


    Array of type EObjectTypeQuery

    One element set to Pawn


    Vector 3







    None - 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.

The variable DesiredObjectTypes is an Array of the type EObjectTypeQuery with a single element set to Pawn. To do this, select the DesiredObjectTypes variable in the My Blueprint panel, then in the Details Panel, under the Default Value category, click the plus_button.png button to add an element. Using the pull down on that element, select Pawn.

If the Default Values category doesn't show anything, Compile the Blueprint.

Here is what is going on in this graph:

  1. Event Tick works just like the same even in Actors, except it is ticked at a rate defined in the Behavior Tree.

  2. The Owner Actor passed in is always the Controller calling the Behavior Tree, so let us store that. But, only do that if we don't already have it stored, just to reduce some overhead from the cast node.

  3. Do a Multi Sphere Trace for Objects based on the location of the controlled pawn, and get all the pawns, minus the controlled pawn.

  4. The For Each loop then figures out if the player was hit.

  5. If it is, do a visibility trace to see if our AI pawn can see the player pawn.

  6. If yes, set the appropriate values on the blackboard object for the AI pawn (Target to Follow and Target Location).

  7. If no, clear the Target to Follow key on the blackboard.

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