How can I make an enemy AI patrol and also detect the player only within a specific cone of vision?

I’m trying to make a simple AI enemy that patrols between points and only chases the player when they’re inside a defined field of view. I’ve set up a Behavior Tree and Blackboard, but I’m confused about how to accurately calculate vision cone detection. Should I use line traces, perception components, or something else?

Doesn’t AI peception do it on its own? With Sight radius?

As Jaswanth07 said, Ai Perception is intended to handle this. Some configuration i have found is only accessible in C++ ( for me, changing the angle of the cone is C++ only. I needed the character to look down.)

A short description is that you add a sight stimulus component to your character and Ai perception to your npc, and the AI perception will fire an event when it detects characters with the correctly configured Perception stimulus

1 Like