Skip to content

Behavior Public API

Pro Behavior

This page documents the supported public API for the Behavior System.

The Behavior System public API is intentionally small. Use it to execute behavior libraries and to add project-specific behavior functions. Editor widgets, outliner rows, details customizations, drag-drop operations, binding internals, operator internals, registry mutation functions, and evaluator internals are implementation details.

Some reflected types are visible from public headers because Unreal assets and UHT need them. Visibility does not make them a stable extension point.

AreaSupported entry pointUse for
Behavior Library assetsUJ2TagBehaviorLibraryAssetStoring behavior sections, rules, actions, overrides, and execution settings.
Behavior execution helpersUJ2TagBehaviorBlueprintLibraryExecuting behaviors, creating behavior contexts, and reading event context in Blueprint.
TagSet behavior mappingsUJ2TagSetAsset behavior resolver functionsReading behavior mappings from TagSets, groups, and tags.
Blueprint behavior functionsBlueprint classes derived from UJ2TagBehaviorBlueprintLibraryCustom Blueprint expressions and actions.
C++ behavior functionsNative classes derived from UJ2TagBehaviorFunctionLibraryBaseCustom native expressions and actions.

Class:

UJ2TagBehaviorLibraryAsset

Behavior Library assets are authored in the Behavior Editor and referenced by TagSets, groups, and tags.

Important data areas:

AreaPurpose
ActionGroupsPrimary behavior structure made of rules and actions.
StepsCompatibility list for older linear workflows.
ThemeColorsColors for cards and visualization.
SourceEventEvent that triggers the behavior.
PriorityLower values execute earlier.
bEnabledEnables or disables the behavior.
DebugLogModeExecution logging mode.

Class:

UJ2TagBehaviorBlueprintLibrary

Use this class as the Blueprint utility API for behavior execution and context helpers.

Typical utility API:

  • ExecuteBehavior
  • TriggerBehaviorEvent
  • MakeBehaviorContext
  • SetContextString, SetContextBool, SetContextInt, SetContextFloat, SetContextObject, SetContextClass
  • GetEventActor, GetEventComponent, GetEventTagName, GetEventSourceObject
  • GetRegisteredFunctionCount, GetAvailableFunctions, GetFunctionCategories

Class:

UJ2TagSetAsset

TagSet assets can provide Behavior Library mappings at the TagSet, group, and tag level. Use the resolver functions when project code needs to inspect the effective behavior setup.

Important behavior resolver functions:

  • ResolveTagSetBehaviors
  • ResolveTagSetBehaviorSections
  • ResolveGroupPolicies
  • ResolveGroupBehaviorSections
  • ResolveTagBehaviors
  • ResolveTagBehaviorSections

Custom behavior functions are the supported extension point for project-specific Behavior System logic.

Authoring modeRequired base classResult
BlueprintUJ2TagBehaviorBlueprintLibraryCustom Blueprint functions become Behavior expressions or actions.
C++UJ2TagBehaviorFunctionLibraryBaseCustom native functions become Behavior expressions or actions.

The behavior registry accepts functions only from:

  • UJ2TagBehaviorBlueprintLibrary Blueprint classes
  • UJ2TagBehaviorFunctionLibraryBase native classes
  • the built-in UJ2TagBehaviorFunctionLibrary

Class names alone are not enough. A class named MyBehaviorFunctionLibrary is ignored unless it derives from the supported base class.

Create a J2 Tag Behavior Function Library asset and add functions to it.

Rules:

  • pure Blueprint functions are shown as expressions
  • non-pure callable Blueprint functions are shown as actions
  • input pins become behavior inputs
  • output pins and return values become behavior outputs
  • hidden World Context pins are provided automatically
  • function names and pin names should be treated as serialized API

Derive from UJ2TagBehaviorFunctionLibraryBase:

#pragma once
#include "Behavior/J2TagBehaviorFunctionLibraryBase.h"
#include "MyBehaviorFunctions.generated.h"
UCLASS()
class UMyBehaviorFunctions : public UJ2TagBehaviorFunctionLibraryBase
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category = "Project|Validation")
static void HasRequiredPrefix(FName Tag, FName Prefix, bool& Result);
UFUNCTION(BlueprintCallable, Category = "Project|Validation")
static void WriteValidationMessage(UObject* TargetObject, const FString& Message, bool& Result);
};

Example implementation:

void UMyBehaviorFunctions::HasRequiredPrefix(FName Tag, FName Prefix, bool& Result)
{
Result = Tag.ToString().StartsWith(Prefix.ToString());
}
void UMyBehaviorFunctions::WriteValidationMessage(UObject* TargetObject, const FString& Message, bool& Result)
{
Result = IsValid(TargetObject) && !Message.IsEmpty();
}

Recommended parameter patterns:

  • use reflected Unreal types such as bool, int32, float, double, FString, FName, FText, FVector, FRotator, FTransform, FGameplayTag, UObject*, and TSubclassOf<UObject>
  • use output reference parameters such as bool& Result, int32& Count, or a typed output name
  • keep categories and tooltips descriptive because the Behavior Editor displays reflected metadata
  • prefer Result for the primary output when the function returns a condition or success state

Avoid:

  • maps, sets, delegates, interfaces, latent functions, and unsupported reflected parameter types
  • direct access to Behavior Editor widgets, panels, outliner nodes, or customization classes
  • directly registering or mutating functions through the behavior registry from project code
  • renaming functions, owner classes, input pins, output pins, or override paths after assets use them

See also: