Friday Facts #345 - Unit group collision mask & Artillery shell particle

Posted by Klonan on 2020-05-01

Unit group collision mask

Last weekend, a bug report came in on our forum. The issue was that the groups of biters were trying to path over the water, but the bugs can't swim.

It seemed like something quite typical of a mod being funky. I looked into it, and it seems the Hovercraft mod was playing monkey business with water collision masks to make his vehicles ride over water. One thing involved setting water tiles to be walkable, and then adding an additional collision layer to all players and biters.

What this modder didn't realise though, is that unit groups have a fixed collision mask. It used to be hardcoded, but a while ago it was added to the utility constants. So we just say "hey its a mod problem, here's a quarter, call someone who cares"... right?

Well it didn't sit right with me, because deep inside I knew that the unit groups shouldn't have a fixed collision mask, it doesn't make sense really. Lets say you add flying units to the game. If you give individual commands to the flyers to go attack the base, they will happily fly over the water and attack without issue. However if you put them in a group together, a group of flying units, the group will path around the water, because the unit group still has a fixed ground collision mask.

So this week I decided to fix it once and for all. It turns out it wasn't so hard in the end. As we mentioned somewhat in FFF-340, unit groups already have logic in place to recalculate their properties based on their members. I hooked into that logic to also make them recalculate their collision mask.

The way that made sense to me, is that they should add the masks together, so that they only path where all of the units can path.


A group of only small biters, they can't walk on water, so they walk around it.


A group of 'water biters'. They can walk right over water, so they go straight through.


A mixed group of small biters and water biters. They add their masks together, so only go where all the units can go.

You can imagine it quite intuitively I think, the group will try to stick together, and that will mean the group can only path to places that all the members can reach.

It feels quite nice to make fixes like this, as they are relatively small in scope and risk, but cleanup a lot of potential problems, and open a lot of interesting possibilities.

Artillery shell particle effect

Another nice small finishing touch for you all this week. Adding a shell being ejected from the Artillery cannons was suggested back when we showed the new sounds integrated into the game (FFF-341). While we can't get too fancy with it, we think the relatively straightforward effect that we've added fills in the detail nicely.

It is just a particle with a nice spritesheet that Dom rendered from the original shell models. With a bit of engine tweaking here and there, we had it ready in quite short order. Just another small bit of polishing that characterises this stage of development.