RealDocs

UBehaviorTreeComponent::IsExecutingBranch

function AIModule Since 4.0
#include "BehaviorTree/BehaviorTreeComponent.h"
Access: public Specifiers: const

Description

Returns true if the active node is currently executing somewhere underneath the given node (optionally restricted to one specific child branch). Commonly used from decorators to check whether their own subtree is the one currently running.

Caveats & Gotchas

  • With the default ChildIndex of -1, it checks whether the active node is anywhere under Node at all, not under a specific child — pass an explicit child index for branch-specific checks.
  • Cheap to call from Tick/OnNodeUpdate-style decorator callbacks, but it walks execution indices, so avoid calling it in tight loops over many nodes per frame.

Signature

bool IsExecutingBranch(const UBTNode* Node, int32 ChildIndex = -1) const

Parameters

Name Type Description Default
Node const UBTNode* Composite or decorator node to test as an ancestor of the active node.
ChildIndex int32 If set, restricts the check to the branch under this specific child index of Node rather than any of its children. -1

Return Type

bool

Example

Decorator checking if its own branch is active C++
bool UBTDecorator_MyCondition::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
{
    return OwnerComp.IsExecutingBranch(GetParentNode(), GetChildIndex());
}

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.