Behavior Public API
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.
Supported Entry Points
Section titled “Supported Entry Points”| Area | Supported entry point | Use for |
|---|---|---|
| Behavior Library assets | UJ2TagBehaviorLibraryAsset | Storing behavior sections, rules, actions, overrides, and execution settings. |
| Behavior execution helpers | UJ2TagBehaviorBlueprintLibrary | Executing behaviors, creating behavior contexts, and reading event context in Blueprint. |
| TagSet behavior mappings | UJ2TagSetAsset behavior resolver functions | Reading behavior mappings from TagSets, groups, and tags. |
| Blueprint behavior functions | Blueprint classes derived from UJ2TagBehaviorBlueprintLibrary | Custom Blueprint expressions and actions. |
| C++ behavior functions | Native classes derived from UJ2TagBehaviorFunctionLibraryBase | Custom native expressions and actions. |
Behavior Library Assets
Section titled “Behavior Library Assets”Class:
UJ2TagBehaviorLibraryAssetBehavior Library assets are authored in the Behavior Editor and referenced by TagSets, groups, and tags.
Important data areas:
| Area | Purpose |
|---|---|
ActionGroups | Primary behavior structure made of rules and actions. |
Steps | Compatibility list for older linear workflows. |
ThemeColors | Colors for cards and visualization. |
SourceEvent | Event that triggers the behavior. |
Priority | Lower values execute earlier. |
bEnabled | Enables or disables the behavior. |
DebugLogMode | Execution logging mode. |
Execution Helpers
Section titled “Execution Helpers”Class:
UJ2TagBehaviorBlueprintLibraryUse this class as the Blueprint utility API for behavior execution and context helpers.
Typical utility API:
ExecuteBehaviorTriggerBehaviorEventMakeBehaviorContextSetContextString,SetContextBool,SetContextInt,SetContextFloat,SetContextObject,SetContextClassGetEventActor,GetEventComponent,GetEventTagName,GetEventSourceObjectGetRegisteredFunctionCount,GetAvailableFunctions,GetFunctionCategories
TagSet Behavior Mappings
Section titled “TagSet Behavior Mappings”Class:
UJ2TagSetAssetTagSet 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:
ResolveTagSetBehaviorsResolveTagSetBehaviorSectionsResolveGroupPoliciesResolveGroupBehaviorSectionsResolveTagBehaviorsResolveTagBehaviorSections
Custom Behavior Functions
Section titled “Custom Behavior Functions”Custom behavior functions are the supported extension point for project-specific Behavior System logic.
| Authoring mode | Required base class | Result |
|---|---|---|
| Blueprint | UJ2TagBehaviorBlueprintLibrary | Custom Blueprint functions become Behavior expressions or actions. |
| C++ | UJ2TagBehaviorFunctionLibraryBase | Custom native functions become Behavior expressions or actions. |
The behavior registry accepts functions only from:
UJ2TagBehaviorBlueprintLibraryBlueprint classesUJ2TagBehaviorFunctionLibraryBasenative 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.
Blueprint Function Libraries
Section titled “Blueprint Function Libraries”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
C++ Function Libraries
Section titled “C++ Function Libraries”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*, andTSubclassOf<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
Resultfor 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: