Posted August 07, 2022 by jofbob
This week I had a lot of fun with navmeshes. Navmeshes are a way to create environments and objects which AI are able to navigate by themselves, all through Unity's inbuilt methods. Pretty snazzy!
I started by adding navmeshes into my chicken scene from last week, additionally making each fence a nav mesh obstacle. I implemented a basic agent which moved to where my mouse clicked.
I had to bump up my agents speed a lot due to my scene scaling, and discovered something interesting - perhaps obvious. Here, my capsules speed is set to 50, and acceleration at 40.
And here, its acceleration is set to 75.
Notice how it takes a much sharper corner around the fence due to its fast acceleration. This is pretty obvious in hindsight, but I think it is interesting how the acceleration changes the curve of movement due to overshoot.
Anyway, chickens. My chicken spawning method needed an upgrade, so I added raycasted mouse spawning for them. This lets me spawn my chickens wherever I want! Here we can see the public execution multiple chickens for their non-existent sins. The Farmer is an evil man.
But the chickens want a revolt! I gave them the ability to navigate the scene, and urged them to chase down the farmer.
i found this pretty funny. I created two gifs because I couldn't decide which one was my favourite.
Thanks for reading :)