Skip to content

GameplayBehavior

8 tools for Gameplay Behavior configs, and triggering or ending a behavior on an actor.

Back to the index.

create_behavior_config

Destructive Idempotent

Get or create a UGameplayBehaviorConfig data asset at package_path/config_name: create it, or load the one already there, set its protected BehaviorClass by reflection when behavior_class is given (on an existing config this overwrites its class), then save it in every case; no undo step. Use it as the entry point before trigger_behavior_on_actor; to change only the class of a config use set_behavior_class, to read one get_behavior_config_info, to find them list_behavior_configs, and to delete one remove_behavior_config. A behavior_class that does not resolve, names two classes, or is not a UGameplayBehavior subclass is an error, checked before anything is created or loaded, so nothing changes. behavior_class and behavior_class_path in the reply are read back from the config (empty when unset); created tells new from existing. Idempotent: the same call again leaves the same asset. An asset of another class at that path is an error. A failed save (always while PIE runs) makes success false with saved=false.

Parameter Type Required Description
config_name string yes Asset name of the config, no folder, e.g. "BC_Patrol".
package_path string no Destination content folder as a long package path, e.g. "/Game/AI/Behaviors" (default /Game/MCP).
behavior_class string no UGameplayBehavior subclass to run: a class path, e.g. "/Script/GameplayBehaviorsModule.GameplayBehavior_AnimationBased" or "/Game/AI/GB_Sit.GB_Sit_C", a Blueprint asset path ("/Game/AI/GB_Sit"), loaded if needed, or the exact name of a loaded class ("GameplayBehavior_AnimationBased", "GB_Sit_C"). Omit it to leave the class as it is.

Returns: { config_path: string, config_name: string, behavior_class: string, behavior_class_path: string, created: bool, saved: bool }

end_behavior_on_actor

Destructive Idempotent

Interrupt the gameplay behaviors that the editor world UGameplayBehaviorSubsystem runs on a Pawn found by its label: every running behavior that is a behavior_class (subclasses included), or every one when behavior_class is omitted, gets EndBehavior with interrupted=true. behavior_class is a class path, or the exact name of a loaded UGameplayBehavior subclass; a name two classes share, or one that does not resolve to such a class, is an error and nothing stops. ended is read back from the subsystem: true once every matching behavior stopped, while still_running counts the ones that did not and makes success false. With none running it succeeds with ended false and a note, so a repeat call is idempotent. Runtime only: nothing is saved or undoable. A missing actor, a non-Pawn or no subsystem is an error. Start one: trigger_behavior_on_actor; subsystem check: get_behavior_subsystem_info.

Parameter Type Required Description
actor_label string yes Label of the Pawn actor in the editor world.
behavior_class string no Optional UGameplayBehavior subclass to stop: its path, e.g. "/Script/GameplayBehaviorsModule.GameplayBehavior_AnimationBased", or its exact class name ("GameplayBehavior_AnimationBased"); omitted stops every behavior on the pawn, and one that does not resolve to such a class is an error

Returns: { actor_label: string, behavior_class: string, ended: bool, stopped_count: int, still_running: int, note?: string }

get_behavior_config_info

Read-only

Read the protected BehaviorClass of a UGameplayBehaviorConfig asset by reflection: behavior_class (class name), behavior_class_path and has_behavior_class. Read-only; set it with set_behavior_class, or list every config with list_behavior_configs.

Parameter Type Required Description
config_path string yes Path of the UGameplayBehaviorConfig asset, e.g. "/Game/MCP/BC_Patrol"

Returns: { config_path: string, behavior_class: string, behavior_class_path: string, has_behavior_class: bool }

get_behavior_subsystem_info

Read-only

Report whether the editor world has a UGameplayBehaviorSubsystem (UGameplayBehaviorSubsystem::GetCurrent): world_name, subsystem_available and, when it exists, subsystem_class. Read-only, no parameters; trigger_behavior_on_actor and end_behavior_on_actor fail without it.

No parameters.

Returns: { world_name: string, subsystem_available: bool, subsystem_class: string }

list_behavior_configs

Read-only

List the UGameplayBehaviorConfig assets under package_path, recursively, from the Asset Registry, without changing them: each config path and name with the name of its BehaviorClass (empty when unset), plus total. Each match is loaded to read that protected field, so a big folder costs one load per config. Only assets whose class is exactly UGameplayBehaviorConfig are listed: subclass configs such as GameplayBehaviorConfig_Animation or GameplayBehaviorConfig_BehaviorTree, and Blueprint subclasses, are skipped. The configs come sorted by config_path, a page at a time (offset/limit); no match is total 0, not an error. One config in detail: get_behavior_config_info; create one: create_behavior_config; set its class: set_behavior_class; delete one: remove_behavior_config.

Parameter Type Required Description
package_path string no Optional content folder searched recursively (default "/Game"); an empty string also means /Game, so another mount point needs its own path
offset integer no Index of the first entry returned, counted from 0 (default 0). Read the next page at the reply's next_offset.
limit integer no Most entries returned per call, 1..1000 (default 100).

Returns: { package_path, configs:[{ config_path, config_name, behavior_class }], total: int, offset: int, limit: int, returned: int, truncated: bool, next_offset: int|null }

remove_behavior_config

Destructive Idempotent

Destroy a UGameplayBehaviorConfig data asset (mirror of create_behavior_config). Typed-delete: it loads the asset and REFUSES to delete it if it is not a UGameplayBehaviorConfig, so it cannot wipe the wrong asset the way the generic delete_asset can; that refusal, and a delete the engine does not carry out, make success false with deleted false. Idempotent on missing assets.

Parameter Type Required Description
config_path string yes Full /Game/... asset path of the config.

Returns: { config_path, deleted, already_existed, asset_class?, note? }

set_behavior_class

Destructive Idempotent

Set which UGameplayBehavior class an existing UGameplayBehaviorConfig asset runs (its protected BehaviorClass, written by reflection), then save the asset; no undo step. Use it to repoint a config; create_behavior_config makes a new one, get_behavior_config_info reads the class back, list_behavior_configs finds configs. A config that does not load, a class that is not found, names two classes, or is not a UGameplayBehavior subclass is an error and nothing changes. The class is read back from the config after the write: set is true only when it holds the class asked for, and otherwise success is false and nothing is saved. Idempotent: the same class again writes and saves again. A failed save (always while PIE runs) makes success false with saved=false.

Parameter Type Required Description
config_path string yes UGameplayBehaviorConfig asset as an object or package path, e.g. "/Game/MCP/BC_Patrol", as list_behavior_configs returns it.
behavior_class string yes UGameplayBehavior subclass to run: a class path, e.g. "/Script/GameplayBehaviorsModule.GameplayBehavior_AnimationBased" or "/Game/AI/GB_Sit.GB_Sit_C", a Blueprint asset path ("/Game/AI/GB_Sit"), loaded if needed, or the exact name of a loaded class ("GameplayBehavior_AnimationBased", also with the C++ "U" prefix, or "GB_Sit_C").

Returns: { config_path: string, behavior_class: string, behavior_class_path: string, set: bool, saved: bool }

trigger_behavior_on_actor

Destructive

Start the behavior of a UGameplayBehaviorConfig on a Pawn found by label in the editor world: the config supplies its UGameplayBehavior, whose Trigger runs on the pawn, and the world UGameplayBehaviorSubsystem tracks it until it ends or end_behavior_on_actor stops it. triggered=false means the behavior refused. Runtime only: nothing is saved or undoable. A config without BehaviorClass (see set_behavior_class), no subsystem in the editor world (see get_behavior_subsystem_info), a missing actor or a non-Pawn is an error.

Parameter Type Required Description
config_path string yes Content path of the UGameplayBehaviorConfig.
actor_label string yes Label of the Pawn actor in the editor world to receive the behavior.

Returns: { config_path: string, actor_label: string, behavior_class: string, triggered: bool }