In this lesson, you will learn how to architect a priority system that enables your AI to intelligently decide which stimulus—vision, hearing, or damage—demands immediate attention when they occur at the exact same time.
The Conflict of Sensory Input
When an AI is bombarded with multiple stimuli, processing them sequentially can lead to "input flickering," where the AI constantly switches its focus between a noise to its left and a visual target to its right. To solve this, we implement a Stimulus Weighting System within our Perception component's delegate callback.
Instead of immediately pushing data to the Blackboard, we store incoming stimuli in a temporary buffer. Each stimulus type is assigned a weight: Damage (High), Vision (Medium), and Hearing (Low).
Building the Priority Logic
When OnTargetPerceptionUpdated triggers, we compare the current "Active Threat" against the incoming stimuli using a simple evaluator function.
// Logic to determine priority
float GetStimulusPriority(FActorPerceptionBlueprintInfo& Info) {
if (Info.LastSensedStimuli.Contains(DamageTag)) return 3.0f;
if (Info.LastSensedStimuli.Contains(VisionTag)) return 2.0f;
if (Info.LastSensedStimuli.Contains(HearingTag)) return 1.0f;
return 0.0f;
}
By comparing the priority of the new stimulus against the currently stored threat in the Blackboard, you ensure the AI only pivots its attention if the new input is more critical. If an AI is currently chasing a target (Vision) and receives a distraction (Hearing), the system checks the weights: Vision (2.0) > Hearing (1.0). The logic suppresses the update, keeping the AI focused on the primary threat. However, if the AI takes Damage (3.0), the system forces a state transition regardless of the current target.
This approach creates a robust hierarchy where your AI prioritizes immediate physical harm over visual investigation, and visual investigation over mere noise, preventing the erratic behavior often seen in less sophisticated perception systems.
Key Takeaway: Implement a weighted priority check before updating Blackboard keys to ensure your AI maintains focus on the most threatening stimulus during simultaneous sensory events.