Unity Enemy With Movement-Based Vision
- Nolan Roher
- May 6, 2019
- 1 min read
This script is for an enemy that detects a player based on movement through an area that is designated as its territory. When the script starts the enemy creates an array of planes to create a cube that generates its territory. As the game runs the enemy uses an OverlapBox to find all the objects with colliders in its territory, then it runs through all those objects to see which have rigidbodys, then if one of those objects moves faster than the enemy's DetectSpeed the enemy will then proceed to chase after them as long as they are above the DetectSpeed, if the object stops moving fast enough to be detected then the enemy will check the last known location inside that territory before returning to the center of that territory.


Comments