Enemy stop moving when stared at

I started unity, and scripting a month ago and I am trying to make a monster where if you look at him, he doesn’t move (similar to SCP Containment breach, and Slender). I currently have a block childed to the camera, and want it so when the collider hits the monsters collider, he freezes. Can anyone start me off on a script? Thanks in advance

Well, to see if it is within view of any camera, you can check renderer.isVisible:

if(renderer.isVisible) //Checks to see if is viewed by a camera

if you mean, is it in line of sight of the character, that’s a bit more complicated though, you would probably use a raycast forward from the character object…
Beware: This includes if it is viewed by the editor camera, so while simulating your scene, if your enemy runs where your editor camera is looking, it will output if(renderer.isVisible) as true, so you’d have to be careful to make sure during testing that the camera is looking at the sky or something.