Ready-made StateTree tools for Unreal Engine 5
Plugin: StateTreeToolsCore
Class: UPerceptionEventForwarder
Bridges the AI perception system and the StateTree event system. Add this component alongside a UAIPerceptionComponent on an AI controller or character. At runtime it listens to the perception component’s delegates and fires StateTree events whenever a target is detected or forgotten, so your StateTree can react to perception without any custom C++.
Both events are sent to all UStateTreeComponents on the same actor (or filtered to one by name — see State Tree Component Name below).
StateTreeTools.Events.Perception.TargetUpdatedFired by OnTargetPerceptionUpdated. The event payload is FTargetPerceptionUpdatedPayload:
| Field | Type | Description |
|---|---|---|
Actor |
AActor* |
The perceived actor |
Stimulus |
FAIStimulus |
Full stimulus data — sense class, strength, age, success flag |
Attitude |
ETeamAttitude |
Relationship between owner and perceived actor (Friendly, Neutral, Hostile) |
StateTreeTools.Events.Perception.TargetForgottenFired by OnTargetPerceptionForgotten. The event payload is FTargetPerceptionForgottenPayload.
Requires UE 5.2 or later. The
OnTargetPerceptionForgottendelegate was added toUAIPerceptionComponentin UE 5.2. On UE 5.1 onlyTargetUpdatedevents are fired.
| Field | Type | Description |
|---|---|---|
Actor |
AActor* |
The forgotten actor |
Attitude |
ETeamAttitude |
Relationship between owner and forgotten actor |
The name of the UStateTreeComponent on the owner to send events to. Leave as None (default) to broadcast to every StateTree component on the actor. Set this if the actor has multiple StateTree components and you want to target only one.
UAIPerceptionComponent to your AI character or controller and configure the senses you need (e.g. Sight, Hearing).UPerceptionEventForwarder to the same actor.StateTreeTools.Events.Perception.TargetUpdated or StateTreeTools.Events.Perception.TargetForgotten.TargetPerceptionUpdatedPayload or TargetPerceptionForgottenPayload. If the payload type is wrong or left unset, the event will not match and the transition will never fire.Payload.Actor, Payload.Stimulus.bWasSuccessfullySensed, Payload.Attitude) using the StateTree binding system.The component logs a warning and becomes inactive if no UAIPerceptionComponent is found on the owner at BeginPlay.