8
Implementing the Pathfinder
One of the coolest features of an RTS game is that the selected units always find the best path to reach their destination, avoiding rocks, trees, buildings, and everything else on their way. There is an AI algorithm behind this feature, called a pathfinder, and it has a few different implementations. In this chapter, we will take a look at the most used algorithms and will focus on the Navigation Mesh (NavMesh).
We will implement the NavMesh on Unity by using the AI Navigation package, setting up our units as agents and the level items as obstacles, and letting the NavMesh find the best path and move the selected units to the destination, avoiding or moving around the obstacles. We are also going to learn how to ...
Get Creating an RTS Game in Unity 2023 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.