Week 4 Tutorial - AI Navigation
This week the goal was to create Artificially Intelligent (AI) characters that could make their way across various terrains and obstacles. In Unity, you can use a Navigation Mesh (NavMesh) to provide information to AI characters about where they can and can't walk.
The picture above illustrates how an AI controlled character would perceive the terrain. The blue areas are traversable by AI, while white areas are marked as an obstacle so the AI knows not to cross into that area. This prevents them from trying to chase the player through a fence, for example, where they would get stuck. The arrows and circles represent places where the AI could safely jump down from one place to another without leaving the traversable area of terrain.
To create an enemy to chase the player, I added some red particles and a red trail to a copy of the player character to clearly identify them. The player can create enemies at any place within the scene by clicking on a point with the mouse. Upon clicking, the game calculates where the mouse is and sends out a laser-like detection beam called a raycast to that specific point on the terrain. Once it has the coordinates of the clicked space, an enemy can be created there.
Once they are born into the world, the enemies access the player's position by searching for the Player's associated "tag", then utilise Unity's Nav Mesh Agent functions to follow a target. In this case, they pursue the player, intelligently navigating their way around obstacles like fences using the data from the Navigation Mesh.
UTAS KIT207 Portfolio
More posts
- Week 6 Tutorial - Cinemachine and Post-ProcessingAug 23, 2022
- Module 5 Devlog - Lighting and Shader GraphAug 16, 2022
- Week 4 Game Ideas DevlogAug 09, 2022
- Module 4 Devlog - A Simple GameAug 09, 2022
- Module 3 Devlog - Terrain and ProBuilderAug 02, 2022
- Week 3 Tutorial - Playable Character in UnityAug 02, 2022
- Week 2 Tutorial - Making a Scene in UnityJul 26, 2022
- Module 2 Devlog - Rigging and AnimationJul 26, 2022
- Module 1 DevlogJul 19, 2022
Leave a comment
Log in with itch.io to leave a comment.