Course contentsShow
← Unreal Engine Game Development
Lesson 398 of 8806. AI, Navigation, and Decision MakingFree lesson

Implementing Pawn Sensing for Basic Awareness

Configure the Pawn Sensing component to detect players through sight and sound triggers to initiate basic AI reactions within your game.

In this lesson, you will learn how to configure the PawnSensing component to enable your AI to "see" and "hear" players, triggering reactive behaviors in your game.

Understanding Pawn Sensing

While sophisticated behavior trees handle complex logic, the PawnSensing component is the classic "eyes and ears" of your AI. It simplifies sensory input by providing two primary events: OnSeePawn and OnHearNoise. By attaching this component to your AIController or the AI character itself, you move beyond static patrolling into active environment awareness.

Configuring the Senses

Once you add the PawnSensing component in your Character Blueprint, you must tune its properties in the Details panel:

  • Sight Radius: How far the AI can see.
  • Peripheral Vision Angle: The field of view cone (e.g., 90 degrees).
  • Hearing Threshold: Determines how loud a sound must be to trigger the OnHearNoise event.

Implementing the Reaction

To make the AI react, you bind these events in your Event Graph. For instance, when OnSeePawn fires, it returns the target actor. You can then verify if that actor is indeed the Player:

// Example logic flow inside your AI Character Blueprint:
// Event OnSeePawn -> Cast to ThirdPersonCharacter -> Set Blackboard Value (Target)

By calling MakeNoise from your Player Character (often triggered by an AnimNotify during a footstep or an action), the AI’s OnHearNoise event will fire. This event provides the location of the noise, allowing you to tell your AI to move to that specific vector using MoveToLocation.

Practical Application

Use OnSeePawn to transition your AI from an "Idle" state to a "Chase" state by updating a Blackboard key. Conversely, use OnHearNoise to force the AI to investigate a suspicious sound, creating a dynamic stealth or combat loop. Because this component handles the heavy lifting of raycasting and distance checks internally, it is highly performant for basic AI setups.

Key Takeaway: Pawn Sensing transforms your AI from a passive entity into a reactive participant by bridging the gap between world triggers (sights and sounds) and your AI’s decision-making logic.