Line of sight implementation

I want to create a line of sight system that checks if a ranged AI can hit / see an enemy take this picture for instance:

Here the Line of sight should fail since the archer is obscured by the wall, however:

In the above picture where the ranged Ai is on the wall, he should be able to see the target.

I have been looking online for a solution with a script to this issue but i haven’t found a good performant way

can anyone help me out? :slight_smile:

If you make your blocking colliders properly, just use Raycast. It doesn’t get any more performant than that.

Remember if you are having performance issues, don’t speculate. Open Window → Analysis → Profiler and figure out what’s going on.

And if you’re raycasting every frame, that’s probably overkill. Do it once a second or so instead.