Make Them See the Player- Game Dev Series 70

S.J. Jason Liu
2 min readJul 5, 2021

--

Objective: create usable eyes to guards.

The adjustment of guards is almost ready. What we should do next is to make them as a threat to our Player.

In this article, we will create functional eyes to those guards to detect the Player. This function is easier than you thought. It just needs some function that we used before.

Create the “eyes”

First we will need to create the eye to all the guards. In here we will use a box collider to do the detection.
Add a cube to all of guards, and adjust the box collider to a proper position, then remove all the mesh renderer.

Set these colliders to trigger. To make a trigger works, we also need to create a rigidbody and disable the gravity.

Next, create a script named Eyes and attach to guards. Let’s create the function of those eyes.

Scripting the eyes

With this script, when the guards detect our Player, it should turn on the game over cutscene that we created. To do that, create a gameobject variable.

The next part is simple, when it trigger to a gameobject with a Player tag, it should activate the cutscene.

Now back to editor, drag the game over cutscene into the script.

All done! All the guards is on duty now.

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.