Raycast from a 3rdp controller

So the issue I’m having is that I’m trying to check if a “enemy” or obstacle is within my visual radius. If it is then set col.gameObject.renderer.enabled = true;
As it is now im only checking if they are within a certain distance of the player, but I want to narrow it down to the field of view.

My characters field of view is cone shaped (he’s holding a flashlight with a spotlight attached to it) and as long as the gameobjects aren’t inside the light they should be hidden (renderers turned off).

What is the best way to solve this, have had a lot of problems with raycasting and such, so I’m now turning to the forum for help

Regards
Robert

Sorry that I haven’t replied. The way I solved it was by checking if an enemy was within my screen(or visual range). Then I calculated if the enemy was within an angle of -22.5 to + 22.5 infront of me. If it was I rendered it, otherwise I didn’t.

Will mark it as solved.