Make Them See the Player- Game Dev Series 70

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store