Look at object and sound playing

Hey, if you noticed, when you playing Slender game, and when you look at slender, jumpscare sound will play. I wanted to do that but I don’t know how to do it. If you guys know, please tell me.

I guess it all depends on how accurate you want it to be. A simple way would just to have a raycast fire from your camera and if it hits him just play the sound.