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…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

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 ,<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 ]. 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 . 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: ]
rf:citation
» How to let our AI see! | Calum Slee | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.