Posted August 06, 2022 by kiaric
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.
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.