This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee
Yesterday, we created waypoints for our AI controlled guards to follow using NavMeshAgents. Today, we are going to give them sight! We want the guards to be able to detect the Player and trigger our game over cutscene.
To set this up, we can create a cube and child it in each guard. Disabling the Mesh Renderer and adding a Box Collider allows us to create a boxed area mimicking the torch light, that will act as a Trigger.
To create the functionality, we need to create a Script. In this script, we are grabbing a reference to the CutScene we want to enable, then we simply use Unity’s OnTriggerEnter method to detect collision. If a collision occurs with the Player, we can activate our cutscene.
How to let our AI see! was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee
Calum Slee | Sciencx (2021-08-26T13:40:24+00:00) How to let our AI see!. Retrieved from https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.