Pathfinding is certainly one of the most important and at the same time most challenging topics in an RTS. How is a tactically demanding battle supposed to work if units cannot even reliably navigate around a wall?
That is why I started working on this topic very early in TacBrain's development. The game uses a multi-stage pathfinding system that takes into account not only obstacles, but also different surface types and their effects on unit movement.
The following video shows how well the implemented solution already works in the current state of development:
The units do not simply detect the wall and calculate a route around the obstacle. Once they reach the other side, they also prefer to use the available road section and only leave the road shortly before reaching their destination in order to arrive at a final position slightly away from it.
There is a concrete gameplay reason for this: vehicles already receive a small movement speed bonus on unpaved roads. Paved roads are also planned and already technically integrated into the game. These provide a correspondingly larger speed bonus.
The following screenshot offers a slightly more technical view of the same scene:
The yellow-highlighted area shows the course of the road. In other words, the pathfinding system has information about which parts of the terrain belong to a road and can take this into account when calculating a suitable path.
In addition, each unit has its own MovementProfile. Among other things, this defines multipliers for movement across terrain as well as on paved and unpaved roads. This makes it possible to control very precisely how different unit types behave on different surfaces.
However, units not only have to deal with the static environment, but also avoid other moving units. For this purpose, TacBrain also includes an RVO simulation.
RVO stands for “Reciprocal Velocity Obstacles” and is used for local collision avoidance between moving agents. Put simply, the system calculates suitable velocities and movement directions that allow units to avoid collisions, while assuming that the units involved react to one another.
For example, when several vehicles meet in a confined space, they can locally adjust their movement direction and speed without requiring an entirely new global path to be calculated for every individual situation.
The system already works quite reliably. However, maneuvering several units in tight spaces can occasionally still look a little unusual at the moment. Situations like these are exactly the kind of areas I intend to refine further during development.