UBehaviorTreeComponent::FindInstanceContainingNode
#include "BehaviorTree/BehaviorTreeComponent.h"
Access: public
Specifiers: const
Description
Searches the current instance stack for the subtree that owns the given node and returns its instance index. Used to resolve which running subtree a node belongs to when working with dynamic subtrees.
Caveats & Gotchas
- • Returns INDEX_NONE if the node isn't found in any currently running instance — always check the result before indexing into instance-related arrays.
- • The search walks the whole instance stack, so avoid calling it every frame from hot paths; cache the instance index once resolved.
Signature
int32 FindInstanceContainingNode(const UBTNode* Node) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Node | const UBTNode* | Node instance (or template) to locate within the running instance stack. | — |
Return Type
int32 Example
Resolving the instance index for a task node C++
const int32 InstanceIdx = OwnerComp.FindInstanceContainingNode(TaskNode);
if (InstanceIdx != INDEX_NONE)
{
uint8* NodeMemory = OwnerComp.GetNodeMemory(TaskNode, InstanceIdx);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?