Tiny Tanks is an 8 player multiplayer game with toy tanks that blow each other up in a completely destructible arena. With hundreds of game modes and modifier combinations, each round is different.
You can blow up the whole map with your mines. Burry your friends below huge piles of debris or make the plummet into the depths of defeat with your cleverly placed explosives. You can blow up the whole map!
Each round is made up of two substantial parts: A Game Mode and up to three Modifiers.
The game mode defines the goals of the round. Instead of shooting each other you might have to hide uner a moving dome, to not get hit by explosives.
To add more fun to the equation you can spice up every game mode with a huge variety of modifiers. A modifier changes a small element of the game to great effect. Here are a few examples:
You can build your own tank from 35 unique tank parts. Not only does your tank look different now, but it even drives different!
Get new ranks, unlock new maps, modes, modifiers and tank parts as you go.
Tiny Tanks features a massive amount of destruction. You can blow up the whole map into small pieces and drive around on them. They influence the gameplay and therefore, we have to somehow synchronize them when you want to play online. But why is that important?
We can we not just run the physics simulation on everyone’s PC and just watch the game run fine? That is because of a thing called determinism, or to be more precise: non-determinism. What does that mean? When we run a deterministic physics simulation a few times, we expect the same things to happen exactly each time. No matter if we run it on a different PC or not. The problem is NVIDIA PhysX is only deterministic under very, very special conditions. Now the problem we face is the following: If we just let the simulation run on everyone’s PC without checking if all the simulations are running exactly the same, we will have great chaos very quickly. For one player half of the map could be gone and another player could still have most of the arena intact. And therefore, we have to make sure that everything is running the same for everyone and if not, we have to correct it to be the same again. Below you can see what it looks like when we force all the players to do the same thing, even if the physics may say something different.
So, how do we do that? The solution is to send so-called snapshots or states from one of the players – the host – to all the other players. However, if we just send the raw states to the other players, we quickly run into trouble. Let’s imagine how much data the host would have to send to the other players. Our standard level consists of 65 blocks, which in turn each consist of 10 debris pieces. The worst-case scenario would be to send updates for each debris 60 times per second, consisting of the position and rotation, taking 16 bytes, totalling roughly 10 Mbits/s having to be sent. Now it doesn’t stop there. This data has to be sent to all the players. For 8 players that would mean the host would have to send 70 Mbits/s, which of course, is not really desirable.
There are a few ways to counter this. The first step is to lower the rate at which the data is sent. We can go down to 20 times per second, that way we can – with the snip of a finger – cut the data by over 60%. Now we just have to add some smoothing, called interpolation to the movement so the debris looks nice and smooth when moving around.
Next, we can use delta compression. That means, we only send data when the values are different. When debris is not moving, we don’t send data. As most of the time the debris are actually not moving, we can save a huge amount of data.
Another technique we can use is to compress the position and rotation. We know that the debris will not move too far away from the centre and we do not have to know the position down to the micrometre. A few centimetres of accuracy is plenty enough. Doing this, we can reduce the size of the individual data from 16 bytes to roughly 6 bytes. Again, we reduced the sent data by roughly over 60%.
Of course, there are a few more tricks, but using just these techniques we can reduce the traffic maximum from 70 Megabits/s to just under 10 Mbits/s. This still sounds like a ton, but remember that this is the traffic we would use up if all debris was to move at the same time. Due to delta compression, we only move 5-20% of the debris at a time. Meaning we realistically need 2 Mbits/s MAX as the host. The rest of the players will need even less.
All of this took us a few weeks to get right and there are more things we had to incorporate. This is just to give you a glimpse at what we are actually doing to make the game run smoothly. We are still working hard towards a satisfying online experience, but we are very close to finishing it.
If you want to stay updated, make sure to follow us on our social media platforms.
Hope you enjoyed the article and thank you for reading,
In this article, we want to share our journey from just a students idea to a full-fledged game. We experienced many great things, met great people and...
No articles were found matching the criteria specified. We suggest you try the article list with no filter applied, to browse all available. Post article and help us achieve our mission of showcasing the best content from all developers. Join now to share your own content, we welcome creators and consumers alike and look forward to your comments.