Tutorial 3
This tutorial, we used our environments from the self study this week along with Unity's AI package to create moving enemies that can traverse complex terrain.
All that was required to prepare our environments for navigation was to add a 'NavMeshSurface' component to the Unity terrain and it would map out everywhere the AI can and can't go with this blue shading.
Now with adding this navigation mesh, all we have to do to make use of it is attach a 'NavMeshAgent' component to a cube, get the NavMeshAgent from the cube and set the target destination and we have an enemy that can chase the player! Taking the player controller from the previous tutorial we can make the scene playable and be chased down by cubes.
Next, there was a section of the tutorial briefly covering raycasting (which I didn't really follow...) so that you could spawn your own enemies into the game with the click of a button at the mouse point on screen. I did mine differently where I raycast from a point (blank transform position attached to the player) forward into whatever is in front of it (so just ahead of where the player is looking) and turned out like this:
Lastly, carving a moving object into the navigation mesh so enemies can avoid them too. Funny enough, that wasn't the hard part. Instead I spent way too long trying to use Unity's Lerp function to move a cube back and forth between two points. Adding another component from Unity's AI navigation package and ticking a box was all the other setup required and now it works!
That's all for this week!
KIT 207 Portfolio
More posts
- Self Study 5Apr 11, 2024
- Game ConceptsApr 01, 2024
- Self Study 4Apr 01, 2024
- Self Study 3Mar 18, 2024
- Tutorial 2Mar 16, 2024
- Self Study 2Mar 13, 2024
- Tutorial 1Mar 08, 2024
- Self Study 1Mar 04, 2024
Leave a comment
Log in with itch.io to leave a comment.