RealDocs

UBehaviorTreeComponent::GetNodeMemory

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

Description

Returns a pointer to the raw per-instance memory block allocated for a node, as configured by that node's GetInstanceMemorySize. This is the low-level accessor behind GetNodeMemory<T> on individual node classes.

Caveats & Gotchas

  • The returned pointer is only valid for the current frame's execution — the instance stack can be reallocated between ticks, so never cache this pointer across frames.
  • Prefer calling GetNodeMemory<T>() on the node itself (which wraps this and does the cast) rather than calling this directly and reinterpret_casting the result.

Signature

uint8* GetNodeMemory(const UBTNode* Node, int32 InstanceIdx) const

Parameters

Name Type Description Default
Node const UBTNode* Node (usually the template) whose per-instance memory block should be returned.
InstanceIdx int32 Index of the instance stack entry that owns the memory block.

Return Type

uint8*

Example

Fetching raw memory for a node instance C++
uint8* RawMemory = OwnerComp.GetNodeMemory(NodeTemplate, InstanceIdx);
FMyTaskMemory* TaskMemory = reinterpret_cast<FMyTaskMemory*>(RawMemory);

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.