Help with Enemy Player Detection Script

Hi Guys,

I’m currently working on a method such that when my player enters the enemies field of vision (FOV), the enemy will move to a position where they can attack the player.

I’ve tried doing this through the use of raycasts to make the boundaries and centre of the FOV, which can be seen like so:1911915--123321--PlayerCollider and Enemy Rays.png

However should the player be in between the rays like so:


he will remain undetected. I understand that I could store the players last position from the initial touch and move like that. However, that still allows the player to enter a position where he will remain undetected as above and remain there.

So onto the question, is there a raycasting method which will allow me to create an arc within which detection can occur?

Can’t you make a vector from the center of the enemy to the center of the player and check if the angle of that vector falls within your FOV?