How to let our AI Guards see

Guard AI Part 5

Tristan Engel
Sep 23, 2021

In this article we will give our guards the ability to see. There are various ways to do this. An example would be using Raycast. Another method is using invisible game object in front of our guards that works as a trigger. This will be used this time.

Turn off the Mesh Renderer Component to make the cube invisible.

Turn on Is Trigger in the Inspector

The gameobject is a child of our guard it moves and rotates along.

Finally we create a script “Eyes” to add to all guards. When the player is detected we enable our game over cutscene.

[SerializeField] private GameObject _gameoverCutscene;

private void OnTriggerEnter(Collider other)
if (other.tag == "Player")
Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

Recommended from Medium