Answer the question
In order to leave comments, you need to log in
How would you make enemy NPC vision for stealth mechanics?
I'm trying to figure out how to implement the following mechanics for a 3D game:
when a player is in sight of an NPC, the NPC attacks. I tried to attach a camera to the NPC and implement a script that reacts to the player's meshes entering the NPC camera's field of view, but then the NPC camera ignores any objects and sees the player through the walls. How would you do it smartly, please share)) not necessarily the code, you can give me some advice so that I know which way to dig. (mechanics for stealth horror game which)
Answer the question
In order to leave comments, you need to log in
No need to do it "on the forehead" as a camera. Solve this question geometrically.
If there is a small distance from the enemy to the player AND the player falls into the field of view (also a common geometric formula) AND there are no walls between the player and the enemy (here is a raycast) - then he is in the field of view.
Of course, you can do it with a pure raycast, or even on colliders.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question