RealDocs

AAIController::RunBehaviorTree

function AIModule Blueprint Since 4.0
#include "AIController.h"
Access: public Specifiers: UFUNCTIONBlueprintCallablevirtual

Description

Starts executing a Behavior Tree on this controller, initializing the Blackboard automatically if the tree has one assigned.

Signature

virtual bool RunBehaviorTree(UBehaviorTree* BTAsset)

Parameters

Name Type Description Default
BTAsset UBehaviorTree* The Behavior Tree asset to run.

Return Type

bool

Caveats & Gotchas

  • Also calls UseBlackboard() internally if the BT asset has a BlackboardAsset set — you do not need to call both.
  • Calling RunBehaviorTree while a tree is already running will restart from the root.
  • Returns false if the BT component couldn't be created or the asset is invalid.

Example

Start a behavior tree when the controller possesses a pawn C++
void AMyAIController::OnPossess(APawn* InPawn)
{
    Super::OnPossess(InPawn);
    RunBehaviorTree(PatrolBehaviorTree);
}

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.