Creating sight cone for characters

Im creating a castle escape game and I have multiple roaming guards. I have attached a cone to the eyes and have set up a collide with camera code. However the sight cone can move through walls and collide with the camera on the other side. Obviously this does not work if the player is hiding behind the wall and should be safe. I was thinking about adjusting the length of the cone as it collides with the wall and gets bigger when not colliding with the wall.

Any ideas on how I might do it?

This is what I got so far.Space