How to Give your AI Eyes

When creating stealth games you want a way for your enemies to detect the player when he is in the open. There is a simple way to do this.

  • first, create a generic cube
  • add it to your enemy and zero out the position to get it to your guard
  • now scale the cube to the size you want the detection area and disable the mesh renderer
  • create a script on your cube
  • if you have created a cutscene for when this happens create a variable to hold the cutscene
  • now when the OnTriggerEnter method detects the player tag it will activate the cutscene
  • add your cutscene to the script and you will be set

Unity Game Developer and C# Programmer