How to Let Your AI See in Unity!!!

Make guard able to caught the player

Objective: create an “eyes” object with a collider and trigger the game over cutscene when it detects the player.

First we have to create a cube game object and place it in front of the guard, this is going to be the vision area of the guard. Also we have to deactivate the mesh renderer component and set the box collider as a trigger.

Then we have to create a new script and attach it to the eyes game object. In the script we have to create a variable to store the reference to the game over cutscene and assign it in the inspector.

Then we have to use the OnTriggerEnter function and check for the player tag to enable the game over cutscene objects.

And that’s it!!!! Now the player is going to be in trouble when entering the guard eyes area.

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.