Creating an AI to Attack the Player
In an RTS game, the battle is one of the most important and challenging features of the game, and it could be the one thing that will make players love or hate the game. Combat must be a fun challenge for the player, and all the actions and decisions must be made by the player during the battle.
In this chapter, we are going to expand the components we have created so far for both units and enemies, adding more physics settings and a new collision component that will work with the NavMesh system to create a solid combat experience for the player. We will also refactor some duplicated code to make it easier for units and enemies to interact with all the new and existing systems.
By the end of this chapter, you will have learned how to set up a solid but flexible physics and collision system, and how it works with a NavMesh system at the same time. You will see how we calculate damage and make the enemy chase the units that are trying to flee...