Project Ant Dev Update

So much for regular updates. It’s been over a year now since I last posted, but here I am again, and Project Ant _is_ still going. There were a few months at the back end of last year and the beginning of this one where I was distracted by, amongst other things: ‘Destiny: The Taken King’, ‘League of Legends’, ‘Rocket League’, the ‘Uncharted Collection’ and ‘Final Fantasies 7, 8 and 10’… Let’s just call it research?

Anyway, development is back in full swing again and there is actually a surprising amount to talk about, so read on to find out what’s new!

The Shoosting Begins!

Combat was a serious undertaking – it required changes to almost every area of the game. There are new animations, new particle effects, new sounds. The entire AI system was overhauled into a new, flexible FSM.

The result is deceptively simple in appearance. Every so often an enemy ant will spawn somewhere in the world and will march towards a room selected by the “Enemy Director”, which helps co-ordinate enemy assaults. Whenever an enemy comes close to another Ant, they will both enter an Engaged state, and will behave according to their current profession. Workers and Builders will attempt to flee – abandoning their current task and using pheromones in the area to attempt to find a route to safety. Soldiers on the other hand will stand their ground and fight to the death, with damage output determined by local pheromone levels as well as hunger and tiredness.

When an enemy ant reaches it’s current target room, it will start attacking it – causing damage and eventually destroying it. Also, if the enemy manages to murder your queen, then it’s game over!

Given the early stage of the game, combat effectiveness is skewed quite heavily in favour of the defender, but given how thick the AI can sometimes be, if you’re unlucky your entire colony can be wiped out by even a small roving death squad.

Joining the Dots!

This update sees another import game system start to take shape – Assignment. Previously, the AI was powered by a universal job queue, which would allocate tasks to ants based on their proximity and profession. This system allowed for no gameplay or flexibility, so it’s now been thrown away in favour of the new world.

As a player, to run your colony successfully you will need to assign objects together to get work done. Assign ants to a store room and they will await orders. Assign the store room to a food source and the harvesting will begin. Some professions (currently the Queen and Builders) are given default assignments (the Queen’s room, and global construction queue respectively) which means that they’ll get work done without being told, but the rest is up to you!

To go along with the combat features, Soldiers can be assigned to an Operations Command (or, ‘Op Com’). By default, Soldiers assigned to an Op Com will patrol the nearby area, however Op Com’s can also deploy beacons, which will send all assigned soldiers to guard the marked area.

A new class of Room has been introduced to the game too – above ground structures. The first of these is the guard tower. This is another building for Soldiers, and supports two assignees who will keep watch over the surrounding area.

All the pretty!

I’ve never been an artist, but as part of this project I’m trying to stretch myself as far as I can go. In this update I’ve tried to give everything a lick of paint to make things look slightly less amateur. The main game now has a parallax background of trees and bushes, while clouds float lazily by in the sky. The day and night cycle has been spruced up with a gradient shader which gives more pleasant-looking sunsets – for bonus snazziness, the clouds are also tinged pink as the sun goes down! To go with the better day and night, every room now has a light which comes on as darkness falls. Gunfire, beacons, and damaged rooms that are on fire all have lights too.

Implementing lighting for rooms was actually a surprisingly involved feature to implement. Meshes in most graphics engines are limited in the number of lights they support at any given time, and Project Ant’s terrain meshes are pretty large – big enough to support far more than Unity’s default of 8 supported lights. To work around this, terrain chunks are now much narrower, and are made of tiles placed in a column. The underground tiles are simple squares for performance, whereas the surface tiles are more complex to keep the terrain generation appearing exactly how it did previously. Tunnels are now offset by a small random value on the z-axis to avoid some z-fighting which becomes apparent when you shine a light on it.

Lighting still isn’t perfect, but it’s not bad for a first pass if I do say so myself!

The main menu has also had some love. It looks much less like a placeholder now with music, marching ants and animated buttons.

The epic refactor

One of the biggest time-sinks, and part of the reason this update took so long and was so motivation sapping, was a massive refactoring of the codebase. As a Unity n00b, the way I originally structured the code involved me enforcing my habits and expectations on the engine rather than following the “Unity way”. As the codebase grew, this became more and more frustrating, until I decided that enough was enough. It took months, and probably about 50 commits, and many thousands of lines of code changed, but I’m much happier with the state of the code now. There’s still some restructuring to do, but we’re getting there.

I’m also now making better use of an open-source dependency injection framework called Zenject. There’s a lot of power in a framework that’s pretty straightforwards by traditional DI standards. It’s definitely something I’ll use in any future Unity projects I pick up.

Onwards and Upwards

So, in conclusion, Project Ant is not dear. In fact, it’s far from it. Github now tells me I’ve just passed the 400 commit mark. There are still plenty of things I’m looking forward to implementing, from tech trees and upgrades, parachutes and pyrotechnics, to enemy colonies, dynamic weather and even possibly a rudimentary online component (not multiplayer though!). Can’t guarantee I’ll post again any time soon, but until next time, feel free to badger me for news or playable demos, or even with ideas!