The Riftbreaker is an action-packed game. You are never truly safe while exploring the alien planet you found yourself on. Even when you’re hiding behind the walls of your base, trying to wait out the night there are thousands of enemies hungry for your skin. Spawning hordes of alien creatures is not a problem, but making them behave in a convincing way is. We would like to show you what steps the developer must take in order to make their game world feel alive.
This article is also available in a vlog form. You can watch it here:
Even if your goal is to have thousands of enemies attack the player at once, the road begins with just a couple of them. Presented below is one of the first prototypes for The Riftbreaker. There is basically nothing there and even the scale of objects is wrong, but it is enough to conduct the first experiments. Placeholder cubes symbolize the enemies and you can see they are trying to locate and reach the player. At that time we were trying to use our old creature collision detection system which we used in Zombie Driver. Each enemy had 3 ray traces in front of their collision body to avoid other entities and world parts.
It may not be pretty, but this is what The Riftbreaker looked like in early 2018.
Well, even if it seemed to work quite well, the algorithm was a bit outdated. It was simply not good enough. We wanted our creatures to be fast and furious and not clumsy. We removed all the ray traces and started using separation and cohesion forces. That gave us nicer movement, which was the first step to our future work. In that time we were playing with math and physics and were testing all our ideas. In this example, a couple of dozens of enemies are chasing the player around, while they slalom among the walls. The enemies funnel through the narrow passages and spread out again once they reach open space. Neat, everything seems to be working fine, but that is just the beginning.
You will never catch me!
Any game would get boring pretty quickly if there was only one type of enemy unit in it. Even in Pac-Man each of the ghosts behaved in a unique way. (Seriously! Check out this article). Galatea 37 is home to multiple species, and all of them are different from each other.
There is one important rule. If a system works with one thing, it must work with many things as well. We needed to test how our math equations will manage with creatures differing in size and speed. Will they stick to each other? Will they able to avoid all the world objects? So many questions needed to be answered at that time. And the only way to that is to put every idea and solution into life. Behold! We present to you the ultimate Canoptrix, Arachnoid and Hammerroceros rush! (They're not slow at all, it is just slow motion. 100% true.)
An accurate visualization of a student's nightmare before a geometry test.
Now is the time for the first test of combat abilities. At this point, we got a little tired of watching colorful cubes running around grey space, so we replaced orange ones with the Zombie Driver Dog model. In this clip, you can see the dogs trying to attack the player, however, there are some defensive towers in the way. The attacks carried out by the monsters and the towers are symbolized by the red and green cubes you can see flying around. This is not only a test of pathfinding, but also attack priorities. We can order the enemies to attack either the player, the energy structures, the defenses or other buildings first. The player is the priority here, but if there is something in the way, it will get destroyed as well.
The first of many epic battles to be fought in The Riftbreaker.
Everything we showed you up to this point was quite small in scale. That does not satisfy us. We want you to get that Starship Troopers feeling when you play The Riftbreaker - thousands of enemies attacking at a time. We set up this scenario to check how the creatures of various types will behave when they are spawned in their own spots all over the map. Red cubes represent flow fields that are pushing them away, which is a very quick way to solve collision problems. They all have a common goal - destroy the human base. The groups will inevitably meet each other along the way - let’s see what happens.
The creatures blend together on their way to the common target, despite different starting points.
Even though the units are limited by the terrain obstacles in the forms of cliffs and pits, the groups manage to blend together and do not block each other’s way to the objective. When they reach a severe bottleneck, they still wiggle around, trying to position themselves to the best of their abilities. That is what will eventually make alien hordes become both terrifying and beautiful - simulating a group of living organisms, rather than robots, each waiting for their turn to cross the passage.
With updated models and animations it all started making sense.
Even so that everything was working pretty well. There was one thing missing. How to get to the fancy level of Starcraft-like unit movement? Everything moves so smoothly and fast in that game, with no movement delay. Well, we tried many things. Praying, watching TV, reading comic books. And guess what, that didn't help us a lot :( But one day our programmer found a solution when he was playing with his young son. They put small balls in a bucket and shook them. Every time, the balls were filling all the empty gaps in the bucket. What magic force was doing that? The answer was - THE FORCE OF GRAVITY. By combining a unique force of gravity for each creature with its very simple soft body simulation, we finally received something similar to Starcraft. With proper looks and animations added, this resembles a game all of a sudden!
The creatures desperately trying to reach the mech in the middle.
We mentioned earlier that it is important for us to make the creatures behave in a believable manner. The last thing we would want our players to see is a bunch of rabid space dogs standing in the field and doing nothing, simply because they currently cannot find a way to reach their target. That is not rabid enough for us. Instead, the creatures group around the target, filling the gaps and behaving like they are controlled by a hive mind. There is only one target, you must reach it by any means necessary. This looks like a living cell, to be honest!
Bug infestation in the base. Little Quelvers are handled by the same systems as all the other units.
The systems we have in place to handle the behavior of units in The Riftbreaker can support both aggressive creatures, as well as neutral ones. Our plan is to fill Galatea 37, the planet where the game takes place, with various ‘ambient’ creatures. Their job is very simple - just go about your day, look for food and water, move from one place to another. The reason behind all this is to make the world more immersive and natural. One such creature is the Quelver - a little scavenger, skittering across the ground in most of Galatean biomes.
Luckily for us, the Quelvers are afraid of the player and their actions, so it's quite easy to get rid of them.
Quelvers’ movements are controlled by the same AI system as other units. In order not to put too big of a strain on the CPU, these creatures appear only outside of combat. If the game detects that the threshold for the number of units in the ‘aggressive’ mode has been crossed, Quelvers will stop spawning immediately. That is not the only performance optimization for these creatures. The game checks where the Quelvers are and spawns them only outside a set radius to avoid clumping them together. No bug geysers in this game. Although it is possible to achieve one if you really want to…
The bugs play an important role in the food chain of Galatea 37, cleaning up the remains.
The little critters also use the same grouping mechanic as the aggressive units, but for a slightly different reason. They group up around corpses, and there are a lot of them after attack waves in The Riftbreaker. Once the fight is ended and the aggressive creature count falls below the threshold once again, the Quelvers will start spawning again and look for bodies to munch on. After a set amount of time, we dissolve the corpses, but the addition of the bugs makes it appear as if they really ate the remains.
The creatures do their best to avoid obstacles while chasing the player.
Finally, it is time to roll out the heavy artillery. The year of developing complex systems and algorithms, thousands of lines of code, countless cups of coffee later, we let thousands of units loose. No more words, let the images speak for themselves.
Did we manage to capture that Starship Troopers feeling? Let us know in the comments and on our Discord server! www.discord.gg/exorstudios We have a lot of new and exciting things coming your way and we can’t wait to show them off!
Other social media: