hey guy i need your help how can i make an ai that uses pawn sense to see if the player is there and when it doesn’t see anybody it will go back to the waypoint to walk around but when it sees u and u enter a collision box it will leave and go back to the waypoint but they is a problem when i came out the ai stopped chasing even do i am standing in front of it i have tried to fix it but nothing is working see the code for both bot and box
The way you set up seems unscalable, and I really encourage you to use a behaviour tree. You will have a lot of trouble if you continue to build on this setup.
Regarding your question, you should use the local class AI Perception controller rather than the pawn sensing. It’s more reliable and scalable. And for the hiding system, it’s much more complicated; you will need to implement an EQS for the most accurate understanding of your level, and without a behaviour tree implementation, you will have a much messier setup.
Hello @ALEX55852 ,Welcome to the forums!
I also recommend using a Behavior Tree, as it will allow you to organize your AI logic in a much more scalable and maintainable way. Although it may seem like a more complex solution at first for simple cases, as you add new behaviors,such as patrolling, chasing, searching, combat, or different alert states, it becomes much easier to expand and modify the AI without having to rework a large portion of the logic.
I’ll leave you this tutorial series, which explains the setup and implementation process very well.
To achieve the behavior you’re looking for, as @56legion mentioned, you could implement it using EQS (Environment Query System).
Smart Enemy AI EQS
However, if you prefer a simpler solution, you can also do it using a Trigger Box along with the following code.
The idea is that when the BP_Character enters the Box Collision, all enemies switch to a Passive state and return to their assigned patrol route (for example, their corresponding Spline). To do this, you’ll need to create that Passive state in your AI(which is explained in the tutorial) and trigger it when the player enters the Box Collision. This way, the enemies will stop chasing the player and automatically resume their patrol behavior.
Hope it helps!


