How to let your AI See!

Let’s create a cube just in front of the security guard and scale it to the length of the area the guard may see.

Create a cube that represents a detection area

Turn off the Mesh Renderer so you can only see the green outline of the collider and on the Collider Is Trigger is checked and rename this object to Eyes. Since the Eyes game object is a child of the Security Guard, where ever the guard moves, the eyes will follow.

Now let’s create the Eyes behaviour by creating a new script named Eyes and attaching it to the Eye game object.

Go ahead and open the Eyes script. The logic would go as follows, in OnTriggerEnter, check if the “other” tag is “Player” and if so then enable the Game Over Cutscene.

Eyes script

Play the game and as you will see, as soon as Darren is in the Security Guards detection area, it runs the Game Over Cutscene.

If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

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

Recommended from Medium

Wavefront as a code using Terraform Integration

Building the Edge Case

Schedule Jobs in Ruby on Rails With Whenever Gem

‘Image credit: Author’

ClickHouse for Machine Learning

Microservice Architecture with Embedded Linux

Transactional Emails for Developers: A comparison of 5 services

Redefining Melio’s Entity Model

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
Jean-Noel Seneque

Jean-Noel Seneque

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

More from Medium

VR Development — Day#4

Aiming Features in Cinemachine

Tessellation in HDRP

Unity : AI [Navmesh implementation (Part III)]