How to let our AI see!

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 cu…

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.


Print Share Comment Cite Upload Translate
APA
Calum Slee | Sciencx (2024-03-29T01:51:08+00:00) » How to let our AI see!. Retrieved from https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/.
MLA
" » How to let our AI see!." Calum Slee | Sciencx - Thursday August 26, 2021, https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/
HARVARD
Calum Slee | Sciencx Thursday August 26, 2021 » How to let our AI see!., viewed 2024-03-29T01:51:08+00:00,<https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/>
VANCOUVER
Calum Slee | Sciencx - » How to let our AI see!. [Internet]. [Accessed 2024-03-29T01:51:08+00:00]. Available from: https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/
CHICAGO
" » How to let our AI see!." Calum Slee | Sciencx - Accessed 2024-03-29T01:51:08+00:00. https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/
IEEE
" » How to let our AI see!." Calum Slee | Sciencx [Online]. Available: https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/. [Accessed: 2024-03-29T01:51:08+00:00]
rf:citation
» How to let our AI see! | Calum Slee | Sciencx | https://www.scien.cx/2021/08/26/how-to-let-our-ai-see/ | 2024-03-29T01:51:08+00:00
https://github.com/addpipe/simple-recorderjs-demo