How to let your AI See!

Using Triggers and Game Events

There are several ways to give sight to my characters. I can do a raycast from it’s eye position or I can use a trigger collider to represent it’s eyes. I am going to go with the quick and simple way. I am using my ScriptableObject Game Event system to play the cutscene.

Setting Up the Eyes

I added a 3D cube to the Guard.

I then Positioned the cube to a spot that I wanted.

I want his sight to be where the flashlight ends while he is walking. I think a Position of 2 on the Z axis and a Scale of 3.5 on the Z axis works really well for me.

I then added a Game Event Trigger to the Eyes.

I then Assign the Game Over Event to the Trigger.

I add the Unity Game Event Listener Component to my Game Manager in the Scene. I assign the Game Over Event as the Event I want to Listen to. In the Unity Response I Activate the Game Over Cut scene and Deactivate the Guards.

Now when the Guard sees the Player the Game is Over.

--

--

--

Excited about changing my hobby into a new carer with GameDevHQ course.

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

Recommended from Medium

Building fast and scalable Master Data Management system using Graph Database

MyBatis over Hibernate. Why?

The next era in cloud computing

Getting ahead of those trying to game a fair distribution for a quick buck and slandering…

Towards Web Accessibility: 7 Lessons We’re Learning

15 Things you can do as Product Owner Improve Team Velocity

A Q&A on Kubernetes Basics, Tooling and More

Hello and welcome to the Geometry.fi Medium.

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
James Lafritz

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.

More from Medium

Completing The White Noise Shader

Creating a Mech Hangar Room

Unity For Beginners

GamePad Support w/ New Unity Input System