#1 Simple “field of view” for a NPC using a Box Collider


Tip #1

Simple “field of view” for a NPC using a Box Collider

 

Hi !

On the tip, I’ll show you a simple method for making a field of view for  IA of your NPC.

You only have to attach a box collider component to your NPC and make it all big as you want, and it must be trigger.

Check this :

Field of View with a trigger box collider

Field of View with a trigger box collider

As you can see on the pic, once you’ve created a trigger zone (green box) , NPC will detect when player, for example, enter into his zone.

To manage that event you must use the message method “OnTriggerEnter(Collider other){}“.

Note that one of two colliders interacting on this event trigger must have a rigid body.

 

See you soon on next tip!

 

Don’t forget leave your comments !

Leave a Reply