Pathfinding Improvements – Coral Viper (1.6.0)
Hello everyone, I’m Miguel (DevM) the gameplay designer at Relic working on pathfinding changes post-launch. I’d like to go over what we have done for pathfinding in both the Year-1 Anniversary update (1.5.0) and the Coral Viper update (1.6.0). Before getting into these, I’m going to cover the feedback and background context driving these changes.
We have gone through various iterations of pathfinding and come a long way since launch. The main goal for the changes were always twofold:
Reduce player frustration.
Create more consistent unit behaviors.
The problem
Company of Heroes runs into a problem that few RTS games do due to the nature of being more closely related to a war simulation game.
While in faster paced RTS titles it’s okay for a vehicle to rotate 180 degrees straight away, and for units to overlap often, in CoH that becomes quite noticeable.
Frustration often results when things happen that are outside your control - like your teammate driving tanks up the frontline and creating traffic jams - this can usually end up with your vehicle getting destroyed. While in some other games that might be more acceptable from a player’s perspective, since each individual unit is less of an investment, in Company of Heroes, a vehicle is a large investment of your time and economy.
Another example of frustrating experiences is when your vehicle reverses into battle, given that front-armor in our game is quite important.
Something that is usually a less obvious problem for players familiar with the franchise is reversing behavior. An experienced player may be used to using the reverse hotkey a lot, but for a newer player that may not be an engrained mechanic.. In fact, most RTS players would not expect required usage of a hotkey for best vehicle movement.
How do we create more consistent behaviors?
Previously we had systems like road preference turned on. This meant vehicles would prioritize moving on roads, often to their detriment. This is an example of sometimes being too smart for your own good. While in theory you get somewhere faster, it also means that once you issue a move order, you’re never sure what your vehicle is going to do. It also becomes heavily map dependent on how the roads are set up. Often in designing these systems, you want to be careful about including behaviors that will mean downstream implications for map designers, since that means every time you author a map you also need to test if vehicles have unexpected behaviors.
This image is a clear example. While following the road is faster (red), the player expectation is the shortest path (green). Following the red path might land you in rough situations where your vehicle comes under enemy fire.
These were the pathfinding items we wanted to tackle for the last 4 months.
- Reversing behaviors.
- Consistency when a vehicle decides to drive forward versus backward.
- Making Casemate vehicles feel better to use.
- Fixing the “circle” issue (referred to by the community as “donuts”).
Before going over what we’ve done, there’s two distinctions we need to make which are hard to get across in patch notes - the difference between the pathfinding algorithm itself and turn plans.
Without overcomplicating things, since there are many underlying systems, to find a path we use A star (A* for short). A* is an algorithm to find the shortest path to somewhere. Company of Heroes works on a grid system, so you can imagine A* telling us which squares we should follow to get to the end location.
However, we often don’t want A* to give us the shortest path, since that would look very unnatural for tanks and possibly frustrating for the player. We want the system to have some leeway. To understand A*, lets look at the following two examples.
Here we follow the shortest path.
Here we try to keep the same overall “direction” as the previous example, but we smooth the curve out.
Turn plans on the other hand are how the vehicle “realistically” interprets the movement to those squares, making the tanks seem more authentic. This could look something like this (green path):
The reason why it’s important to have this context is that when we say “tightening” a curve, it could be on the A* side or with the turn plan.
With these two concepts covered, let’s get into the changes.
Reversing behaviors
One of the changes we made for (1.5.0) is tightening the A* on reverse moves specifically. This should allow vehicles to more closely follow the player’s intent. While the previous implementation meant that the vehicles would get there faster (wider turns means higher speed) it also meant that sometimes it would stay in danger for longer (a wider arc could mean staying inside the arc of fire of an AT-Gun).
The green path is now what we’re choosing. Keep in mind that for frontal movements, it's still important to keep the A* picking somewhat wide paths so that vehicles don’t lose as much speed on turns (especially important when flanking vehicles).
Additionally, turn plans were changed for reverse as well - the range is now halved. This means that if a player doesn’t use the force reverse order, the vehicle will now only reverse much closer to itself. In practice this means that vehicles will choose to get somewhere by reversing less often.
This only fixes the turn plan side of the issue since the A* could still decide to draw a path that’s behind the vehicle and as such the fastest order there might still be to reverse. This already makes it feel a lot better.
More consistency when a vehicle decides to drive forwards versus backwards
As described previously, turn plans are only half the solution. In the following image, even if reverse is less preferred in the turn plan, if it has nothing better it will still reverse into the point.
A* in green, turn plans in orange.
Tied to the previous change, we have made changes once again to how we prefer to path in terms of forwards and backwards. To keep things brief, we have changed how it works so that vehicles prefers moving forward more oftenin these scenarios, so that it looks more like this.
This will alleviate instances where the player clearly wanted to move somewhere with their vehicle front-facing, even if the angle of the click was somewhat behind the vehicle. If players want to still reverse into it, they always have the option to force the reverse through the appropriate command.
There’s also another lever that governs this behavior which we’ve also changed. You can think of it as Sector pathing (let’s call it SP for short). SP governs the A* itself. We use A* for close range squares since doing an A* on our bigger maps would be super expensive. As such SP gives some directives to what the general path should be and A* tries to follow that as close as it can.
We’ve made changes so that this algorithm on top of A* also cares about vehicle facing. This means that for its higher-level calculation it will also make vehicles generally follow paths that are in front of them.
The end result is much more consistent vehicle behaviors. Players can expect front facing movements most of the time unless they are clicking directly behind a vehicle.
Making Casemate vehicles feel better to use:
For casemate vehicles, we noticed that often they would do wide “S” movements, which can feel particularly bad since this unit really cares about its facing. Below of we have an image comparing CoH2, CoH3 live and the new change:
This effectively means that given a move order, the casemate vehicle will be facing the direction a lot sooner, both at the beginning and at the end since the “S” turns were also tightened (on the turn plans). It also means it's less likely to get itself into dangerous situations where it oversteps the forward movement.
In the end we hope this ends up feeling better than even previous CoH games.
Fixing the “circle” issue (referred to by the community as “donuts”).
There were two main problems with this one. One of them is that sometimes turns (turn plans) with big radiuses (which caused the full circle players experienced), were sometimes given too much weight in terms of how fast they were.This meant that vehicles would sometimes prefer a full wide circle that keeps their speed as opposed to just moving in a straight line. This was addressed so that wide turns are deprioritized.
A bonus to this change is that vehicles will now more often choose to do tighter turns which meets player expectations. In the example below the red path is the live game and the green path is the new preferred path.
We feel that these changes will ensure vehicles feel more responsive and fun, while also reducing any previous frustrations with vehicle control. Changes to pathfinding in Company of Heroes 3 have deep cascading effects on the rest of the game, and as such, it often requires ample time for iteration and testing. We know players have wanted to see this addressed quickly, and some feel that we were moving too slowly to respond to pathfinding feedback. However, at the end of the day we wanted to make sure we did not rush this work and that we did it right. Our team is always listening to feedback on how we can improve the CoH experience, and we want to thank everyone for their patience as we kept working on this in the background. Let us know what you think of the changes!