AI¶
7 tools for AI controllers, perception senses and stimuli, and teams.
Back to the index.
add_ai_stimuli_source¶
Additive Idempotent
Adds a UAIPerceptionStimuliSourceComponent to an editor-world actor (or reuses its first one) and makes it a source for the supplied AISense (default Sight): the sense joins the component's RegisterAsSourceForSenses with bAutoRegisterAsSource on, which registers the actor when play starts, and is registered at once where the world has a perception system (the editor world has none: registered_with_perception_system says which). One undo step; the level is dirtied, not saved. registered is the read-back of that list and flag, and false makes success false. An unknown sense is an error. Idempotent: a re-run reuses the component and leaves the list as it is.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Display label or internal name of the target editor-world actor (required) |
sense |
string | no | "Sight" | "Hearing" | "Damage" (default "Sight") |
Returns: { actor_name: string, component_name: string, sense: string, already_existed: bool, registered: bool, registered_senses: [string], auto_register_as_source: bool, registered_with_perception_system: bool }
create_ai_controller_blueprint¶
Additive Idempotent Refused during PIE
Create a Blueprint asset parented to AAIController, compile and save it. Idempotent: if the asset already exists it is loaded and returned, created=false; an asset there that is not an AIController Blueprint makes success false (is_ai_controller=false).
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | yes | Asset name (e.g. BP_EnemyAIController) |
package_path |
string | no | Target /Game package path (optional, default "/Game/Blueprints") |
Returns: { name: string, asset_path: string, parent_class: string, generated_class: string, is_ai_controller: bool, already_existed: bool, created: bool }
get_actor_team¶
Read-only
Reads the native team id (FGenericTeamId) of an actor in the editor world, the team AI Perception uses to tell friend from foe: from the actor itself when it implements IGenericTeamAgentInterface, otherwise from its AAIController when it is a pawn possessed by one; resolved_on says which. When neither implements the interface the call still succeeds, with the engine-reserved NoTeam id 255, is_no_team true and resolved_on "none". Read-only: changes nothing. Editor world only, never a PIE session, so teams assigned at runtime are not seen. An unknown actor is an error. Use it to check set_actor_team, which writes the id; set_native_team_attitude decides whether two team ids are friendly, neutral or hostile; get_ai_perception_senses lists which senses a Blueprint's perception has.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Object name or label of the actor in the editor world (case-insensitive, first match), e.g. "BP_Guard_C_0" (required); a pawn, or the AIController itself. |
Returns: { actor_name, team_id, resolved_on: "actor"|"controller"|"none", is_no_team }
get_ai_perceived_actors¶
Read-only
List the actors that the AIPerceptionComponent of an AI-possessed pawn, or of an AIController, currently perceives by any sense, without changing anything. The actor is looked up in the editor world, not PIE, so an unpossessed pawn is an error. Returns count and perceived [{actor_name}]; no last-sensed time is included.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Object name or editor label of the pawn or AIController in the editor world; the first match is used. |
Returns: { actor_name, perceived: [{actor_name}], count }
set_actor_team¶
Destructive Idempotent
Set the native team id (FGenericTeamId) of an actor in the editor world through IGenericTeamAgentInterface, falling back to its Controller when the actor does not implement it (an ACharacter possessed by an AAIController, the only implementer in vanilla UE 5.8), then refresh that agent's AI Perception listeners so Sight, Hearing and Touch affiliation filtering sees the new team at once. The previous team is overwritten in memory only: no undo step, nothing dirtied or saved, and on an AAIController it is gone when the level reloads. The same id again gives the same result. Read it with get_actor_team; set_native_team_attitude decides whether two teams are friendly, neutral or hostile. An unknown actor, a team_id outside 0-254, or no team interface on the actor or its controller is an error and nothing changes.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Object name or label of the actor in the editor world (a pawn, or the AIController itself), e.g. 'BP_Guard_C_0'. |
team_id |
integer | yes | Team number, an integer in [0, 254], e.g. 1; 255 is the engine-reserved NoTeam id and is refused. |
Returns: { actor_name, team_id (read back from the agent), applied (the read-back id equals team_id; false makes success false), resolved_on: "actor"|"controller", perception_listeners_refreshed, requested: { team_id } }
set_ai_sight_radius¶
Destructive Idempotent
Set SightRadius and LoseSightRadius (default sight_radius times 1.5) on the sight config of the AIPerceptionComponent of an AI-possessed pawn or an AIController. The actor is looked up in the editor world, not PIE, so an unpossessed pawn is an error. Returns sight_radius, lose_sight_radius and sight_sense_count; 0 means no sight config, nothing changed.
| Parameter | Type | Required | Description |
|---|---|---|---|
actor_name |
string | yes | Object name or editor label of the pawn or AIController in the editor world; the first match is used. |
sight_radius |
number | yes | New SightRadius in cm, greater than 0. |
lose_sight_radius |
number | no | New LoseSightRadius in cm, the distance at which an already seen target is lost, 0 or more; default sight_radius times 1.5. |
Returns: { actor_name, sight_radius, lose_sight_radius, sight_sense_count }
set_native_team_attitude¶
Destructive Idempotent
Installs (once per process) a custom FGenericTeamId::AttitudeSolver backed by an MCP-owned symmetric table, then records the pairwise attitude for team_a/team_b. Pairs not explicitly set fall back to the engine's own default (same team -> Friendly, else Hostile). This drives the engine's own AI Perception affiliation filtering (Sight/Hearing/Touch DetectionByAffiliation), which reads FGenericTeamId::GetAttitude directly.
| Parameter | Type | Required | Description |
|---|---|---|---|
team_a |
integer | yes | Required int in [0, 255]. |
team_b |
integer | yes | Required int in [0, 255]. |
attitude |
string | yes | Required: "Friendly"|"Neutral"|"Hostile". |
Returns: { team_a, team_b, attitude, resolved_attitude, solver_installed }