My AI enemy has some serious problems with all its AI senses.

This project I am working on is kind of a stealth game. Here ull have some guards protecting an objective, which ull have to retrieve and extract to a specific extraction zone, on entering which it will show a game over widget with a text “Mission complete”. The AI guards can be distracted by using a gun in our hands that shoots projectile, and wherever the projectile hits, it creates a green sphere, indicating that the AI guard could hear the projectile hitting that surface and then turns around towards that noise. after few seconds, it rotates back to its original position. For now the guards are stationary at one point, they don’t patrol. If the AI enemy or Guard detects me, then it triggers the same game over widget but with a text “You were spotted”. THIS IS THE COMPLETE OVERALL MECHANICS OF THIS GAME

When I fire the projectile, it creates a green sphere indicating that the guard could hear it. It turns around immediately forming a question mark above its head. Upto this much it works, but when the AIGuard is turning around and hears my projectile, it won’t detect my presence, even when I am in his view field. When it detects me, it is supposed to create a yellow sphere, which will indicate that it saw me, but that isn’t happening when it hears me.

If I just simply walk infront of him, it generates the yellow detection indicating spheres and the game over widget just fine, but when I am firing the projectile and he is turning around and facing me, the game over screen is not generating, as if it cant see me there.

One more thing that I noticed for the AI guard is that when I am setting the guard in the world to look at a specific direction initially(Dragging it with mouse), at that time I can obviously see the direction where it can look, when I am playing the game and firing my projectile to distract the guard, it is rotating just fine, but I don’t think his AI senses are rotating with him as well. he is still looking at the same initial direction where I set it to look before hitting the “Play”.
(The green cone shaped component is its view field)
(The yellow and blue spheres around the AI are its hearing fields)


In the above image u can see that my AIGuard is looking at the corner of that somewhat white building’s corner (The objective is right there in that corner). The three red arrows in the bottom part of the above image indicates my way/path of approaching that building’s corner. The ugly white sphere that I drew behind my AIGuard with all the white arrows pointing at it indicates the position where ill fire my projectile and where the green noise sphere will generate.


Now I hit “Play”, and you can see in the above image the AIGuard is looking at the building’s corner, where I set it to look initially, which is perfectly normal at this point.


At first I tried firing the projectile right in front of me and the AI turns around as it can hear the projectile, indicated by that green sphere and looks at me, but no game over UI generates. I believe that the looking component is still looking at that building’s corner only, its just the mesh of the AI that we can see rotate.


Then I fired two projectiles roughly around the area which I marked with the ugly white sphere to divert or distract the AI Gurad, and you can see the mesh rotate towards those noise, But again the AI senses, or the view field(That green cone) of my guard is still set to face towards the building’s corner. As I try to reach that corner, I face the game over screen, even when the AI is turned around in the opposite direction.

Please help me fix this issue!!