- Home /
NPC Field of View reaction
I'm quite new to Unity and I'm having the following problem
I need to get a reaction from a friendly NPC whenever an enemy NPC enters its FOV.
I know I can decide whether a GameObject is in my FOV using Vectors and Raycasts, but the problem lays on getting that GameObject.
Because it's an NPC to NPC interaction I can't simply have a reference to either of them (Because there can be an arbitrary amount of each and I don't want to do the "IsInFOV" check on every enemy every frame...)
I need some way of knowing whether an enemy entered my FOV so I can create my reaction behaviour.
So far I tried the following:
Attaching a camera to the friendly NPC and using the camera functions and raycasts to know if the enemy is seen (It worked fine but I have this bad feeling that it's an abuse and will cause problems later - multiple camera, maybe performance, etc...)
Creating a custom collider and checking for collision with an enemy. This one didn't work (As I said I'm a beginner) but I'm also afraid that having a giant collider will affect later parts of the game (once I start adding items and what not)
Your answer
Follow this Question
Related Questions
AI Field of vision 1 Answer
Issues NPC Grenade avoidance 3 Answers
Can unity3d combined with Artificial Intelligent or Soft Computing? 3 Answers
Simple airplane AI 2 Answers
Helper AI follow character 0 Answers