Here’s a simple detection algorithm which determines if an enemy AI can see the player.
v1 = VNormalize(VSubtract(PlayerPositionVector, EnemyPositionVector)) v2 = VNormalize(VSubtract(EnemyLookAtVector, EnemyPositionVector))
The results will range from 1 to -1. If v1 and v2 are in the same direction (i.e. the player is directly in front of the enemy) the result will be 1. If v1 and v2 are in opposite directions (i.e. the player is directly behind the enemy) the return value will be -1. If the player is directly off to the side of the enemy, it will return 0.
So the enemy can see the player (within 45 degrees in your picture) if the value returned is between 0.7071 and 1.0. If you were using a 60 degree field of view, you would be looking for values between 0.5 and 1.0