Back to main page

Improvements to Unit Behavior

Posted on December 7, 2017 by Kelso

One of the consistent pieces of feedback that we get from players is that the game gets muddy during interior combat and, somewhat, when doing mixed-state combat as well. In the last update we introduced an improvement to this by allowing players to issue orders across world state boundaries. This means that if you have a group of units that are both inside and outside they can be issued attack orders to any enemy they can see regardless of whether or not that enemy matches their world state. In previous versions if you had a squad of units in a building and you told them to attack some enemies that were outside they would – at best – do nothing and sometimes would even break themselves. Same goes the other way around (units that are outside and told to attack enemies that are inside a building). We noticed more than a few instances where players would be confused and/or frustrated because their units were not following the orders they were issuing. That’s resolved now; units are smart enough to go inside or outside to attack a target if they need to. We’re also smart about the other states a unit could be in so, for instance, we won’t move units if they are in cover or in a fire position. Ultimately this all adds up to a command system that feels pretty good. You can select all your units and tell them to attack and the game won’t kick them out of any cover or ambush points that you’ve spent time setting up.

We’re working on improving combat even more in the next update by doing a few things. First – we’re spacing interior units out a bit more when they are idle. Currently, units will use the navigation grid to determine where the closest piece of “open ground” is. This works fine for outside but inside we had to make the graph much more densely packed so units could move around correctly. To fix this we introduced a second graph that has the same spacing as the exterior graph. Units navigate inside buildings using the dense graph and when they reach their destinations or otherwise need to get to open ground they’ll use the less dense graph in order to keep adequate space between them and the other units in the building.

The other big (huge) issue that we have currently is units standing on top of each other when they are moving between destinations or – even more noticeably – when they are attacking. We’d somehow managed to go all this time without doing any kind of logic for unit spacing while in these scenarios. I went back and forth on the best way to do this for awhile and landed on what is basically a passive nudge that units can do within particular states. Essentially, then they are attacking or moving they’ll check for nearby units and nudge themselves away from them until they have adequate space. We do a quick nearby collision check and calculate an average vector based on the collective positions of those units. Then we calculate a steering vector away from that average position and push the unit in that direction. We also do some additional checks based on a unit’s world state to make sure they don’t nudge into an obstacle when they’re outside or out of the building completely when they are inside. We also make sure they don’t nudge themselves off the map edge. We still have some animation snapping that occurs if a unit nudges itself out of attack range and then tries to run back in but this seems to only happen with lots of units or in very compact spaces so for now I think it’s acceptable given the massive improvement it makes to readability and gameplay.

Back to main page