What are some important elements I need to understand when it comes to implementing AI into my projects?

Hello, I’ve been learning to use UE5 for the past couple of months & I thought of creating AI NPCS, specifically ones that go after the player & jumpscare, similar to games like Alien Isolation.

But in the future I want to make it so they can hear sounds & open up hiding spots (e.g A monster opening a locker the player is in.)

Especially things whether or not I should use State Trees or Behavior Trees.

这是关于AI控制器的内容,我建议你直接去看这个视频我的朋友,看完你就知道了(记得关注人家):https://youtu.be/-t3PbGRazKg?si=4rLoQ3-tm9QZcLfY

Hello @5R32 ,Welcome to the forums!
It’s great that you’re learning how to create AI NPCs. It’s a very interesting area to explore because it allows you to create behaviors that make the game feel much more dynamic and immersive. Systems where enemies chase the player, react to sounds, or check hiding spots, among others, can add a lot of tension and depth to the gameplay, especially in horror or stealth games like the example you mentioned.

In my opinion ,for everything related to sounds, sight, and player detection, I recommend using AI Perception. It is specifically designed to handle AI senses, such as Sight (vision) and Hearing (sound). With this system you can easily configure things like vision range, detection angle, or the distance at which an NPC can hear a sound.

When the NPC perceives something, that information can then be used inside the Behavior Tree, which is where the NPC’s decisions are actually made. For example, if AI Perception detects the player, the Behavior Tree can switch to a chase state; if it only hears a noise, it can switch to investigating the area.

https://dev.epicgames.com/documentation/en-us/unreal-engine/ai-perception-in-unreal-engine?application_version=5.5

For more specific things, like an NPC opening a locker , I would also recommend handling it from the Behavior Tree, using a dedicated task for that interaction. For example, the NPC detects something suspicious, moves toward the hiding spot, and executes a task that opens the locker or checks the area.
The Basics to AI - Opening a Door

This way, it makes the behavior clearer, easier to control, and easier to scale as you add more actions or conditions.
If you have any questions, don’t hesitate to ask on the forum!
Hope it helps and happy developing!!

1 Like