Portfolio 6 - Tutorial 3


Navigation

This week, I've been working on character AI in my playground project. This involved first using Unity's built-in navigation mesh generation tools, which essentially gave the AI I developed a surface to operate. I wrote some code that would allow me to place AI enabled characters anywhere in the game world at the click of a mouse, which first gets a point in the world space by casting a ray out from the camera (mapped to the cursor's location), then instantiates an AI enabled character at the position, the base of which is stored as a pre-built object in my project files. As you can see, I used the model and animations of the character I created in earlier portfolio tasks, which did require some tweaking to get to work with my AI code.



The actual AI code itself I designed so that the characters using it would attempt to work in conjunction with the navigation mesh I created to steer the characters towards the player. This is not actually as simple as setting the character's destination to the player's position on the navmesh. Instead, the code estimates where the player will be ahead of time and tries to send the character to intercept, which you can see in the following image:

Notice each character in the horde doesn't try to always run towards the player, but instead as the player turns and starts running in a direction, the horde tries to meet up with the player at the same point.

Leave a comment

Log in with itch.io to leave a comment.