Letting the Enemy See

Tracking the Player Via Colliders

Now that we have our moving Guards AI done, it is time to give them “Virtual Eyes” which allows them to check for the Player. There are various methods in accomplishing this and the solution which I have pick for this project is having an box collider with an script that contains an On Trigger Enter function. This simplistic method is great for quickly testing out game mechanics in a very visual way.

The Eyes

As mention before, our eyes will be created by box collider that is manually placed in front of the Guards. Simply create an 3D cube and have the placement and size adjusted to your desire. Finally have the Mesh Renderer component check off and have the Box collider “Is Trigger” section checked. Also add an Rigidbody component for the Eyes as well since our Player game object does not have one.

The Script

We are going to create a new script for the virtual eyes and apply it to Eyes game object.

Since we are only dealing with the On Trigger Enter method, we can delete everything else that isn’t required. In the On Trigger Enter method we will have an IF statement checking for an game object tag called “Player” and when an object called Player is found, the cutscene will be enabled.

To gain access to the cutscene we will create an Serialized Field of an private Game Object called cutscene. Back in Unity we will be able to drag and drop the desired cutscene that we need.

Getting Captured

--

--

--

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Stream Switched From Python To Golang

Melalie Update #16: The Rise of Mobility as a Service, Technical progress & the next AMA.

NEXT Protocol x Finminity Own-A-Robot Competition Result

Top Jenkins plugins to take your CI/CD pipeline to the next level.

Deploy Django using CloudFormation Template

Web1 vs Web2 vs Web3, in a nutshell

How Meta(Formerly, Facebook) can “fix” misinformation on WhatsApp

How docker make my database a briefcase ?

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
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

More from Medium

Creating the Main Menu

Level Design in Unity Part 2: The Walls

Jump Force

Unity Beginner — Day 03