Detect if player is looking at NPC face?

Basically, making SCP 096 npc. I want to use the dot product to find out if a player is looking directly or atleast a bit a the npc’s face. What would I use in the dot product for this? I don’t want to detect if a player is looking at the entire NPC, I want to detect if the player is looking at a certain angle range at the NPC’S head.


For this stuff, it would be better to use Raycasting

What about grabbing the mouse’s target from UserInputService.InputChanged, I think it would be better than running a Raycast

Thats not what im looking for. I said in the post above that I want to detect when a playing it looking at a certain angle towards the NPC’S face. Raycasting doesn’t help with that at all.

I didn’t mention anything about using the mouse?

I take the game is in first person, so even if you make the mouse texture nothing, it should still work??

anyways, for a more detailed explanation you can use this video to dissect information through angles which is efficient for detection cones (dot products)

you can go through trial and errors of adjusting to reach what you’re satisfied with the angling, you also have to use some raycasting so the scp in question does not get triggered if you look from a obstructed view


Thank you! It works well, although I had to add a second dot product for something else. Adding raycasting wont be an issue.