How to Let Your AI See

If you are somehow following my articles, you have noticed that I have been building a 3D game by using Nav Mesh. In this game, the main character tries to sneak to the vault by passing through some guards. So, this article will be focused on creating the mechanism for making the AI agents to see if the Player character passes within their view points.

Certainly, there are more than one way to do it. First things come to the mind are using Raycasting or a Trigger. For this one, I am going to explain it by using a the Trigger way.

It is actually really simple. Create a game object (like a cube) as a child of the character that we want to create eye sight on. Then, change it’s size according to the desire of yours so that the shape will represent the view points of the agent. Then, deactivate the Mesh Renderer of it, and make sure that you have checked isTrigger. Now, all is left is to adding a script so that it will trigger the game if the Player passes through.

In order to make sure that trigger system work, do not forget to add Rigidbody component to the eyes component you have just created. And actually that’s as simple as it is. Now, our AI Agent have eyes!




Unity Developer

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

Recommended from Medium

#DIGHBS Course Wrap

All Your (d)Base Are Belong To Us, Part 1: Code Execution in Apache OpenOffice (CVE-2021–33035)

Playing With the WSO2 Product-is Test Suite

Best SQL Books

Python for Big Data Programming

Python Loops

HTB Bashed Walkthrough

How to Quickly Convert 2 Lists into a Dictionary in Python

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
Ali Emre Onur

Ali Emre Onur

Unity Developer

More from Medium

Utilizing Faker::Gem and methods to generate fake data

Things to do when you are in B.Tech(CSE)

Offline Color Picker: Pick Color from Images

Setthawut 2021 — A Year of Leear