Course contentsShow
← Unreal Engine Game Development
Lesson 419 of 8806. AI, Navigation, and Decision MakingFree lesson

Managing Task Execution Flow

Learners will master the usage of finish execution nodes to properly signal success or failure to the parent Behavior Tree.

Managing Task Execution Flow

In this lesson, you will learn how to communicate the outcome of your custom AI tasks back to the Behavior Tree using Finish Execution nodes to ensure your AI logic flows predictably.

When you create a Custom Blueprint Task (like a "Patrol" or "Search" task), the Behavior Tree needs to know if that task succeeded or failed so it can decide which branch to execute next. If you don't explicitly finish a task, it will remain "active" indefinitely, effectively freezing your AI’s decision-making process because the parent Sequence or Selector node is still waiting for a result.

Signaling Success and Failure

Inside your Event Receive Execute AI node, you perform your logic—such as moving to a location or waiting for a specific event. Once that logic concludes, you must call the Finish Execution node. This node has a boolean input called Success.

  • Success = True: The Behavior Tree considers the task complete and moves to the next node in a Sequence, or stops execution if it was a Selector.
  • Success = False: The Behavior Tree treats the task as a failure. In a Sequence, this immediately aborts the rest of the sequence. In a Selector, this tells the tree to try the next available branch.

Implementation Example

Imagine a "Find Ammo" task. If the AI finds an ammo crate, you call Finish Execution with Success set to True. If the AI searches the entire area and finds nothing, you call Finish Execution with Success set to False.

// Within your Task Blueprint
Event Receive Execute AI
    -> [Your Custom Logic: Search for Ammo]
    -> Branch: Did we find ammo?
        True  -> Finish Execution (Success: True)
        False -> Finish Execution (Success: False)

By explicitly managing these exits, you prevent "hanging" AI states and allow your Sequences and Selectors to make smart, reactive decisions based on the actual status of your AI’s attempts. Always ensure every possible path through your task logic leads to a Finish Execution node to keep the tree heartbeat alive.

Key Takeaway: The Finish Execution node is your primary bridge for returning state to the Behavior Tree; omitting it causes the execution flow to stall, while correctly toggling the Success boolean allows your AI to dynamically navigate its decision tree.