# How to avoid 2d enemy to see through walls

I am using RayCastCallback to detect the line of sight. So I the enemy avoid seeing the player through walls, problem is there's a limited field of view. So I added another two rays to the left and right side, with a total of 3 rays. Another problem is when the distance is longer the rays can't handle to see the player, so I added another more rays to fill the field of view. I don't know if this kind of idea is good or there is a better way without using rays?

Look in the below image, it seems the there is a circular sensor or like a radar. I am trying to achieve this kind of enemy sight (enemy sight demo ).

I found a solution with the help of box2d, I could create a circle or cone shape as FOV (Field of View) and set as sensor. Now that I could check if the enemy is on the FOV, I could now use a single ray to use in RayCastCallback starting from an enemy position to target position. In this kind of way I could now make the enemy avoid seeing through walls. I have not yet tested this but I think this would work and also I minimize the stress of using multiple rays.