top of page

Tanked : A game I made in a week and one of my most polished works.


Join me on a thrilling weeklong journey into the world of game development, where I, as the sole architect, bring imagination to life through code. Fueled by passion and armed with Unity, I craft a tank warfare game in just seven days, pushing the boundaries of both programming prowess and creativity. Get ready for the behind-the-scenes adventure of transforming a concept into a playable reality.



This blog series delves into my journey as a solo developer, unraveling the intricacies of turning a concept into a playable tank warfare game in Unity. From initial ideas to the final lines of code, join me for a behind-the-scenes exploration of the fascinating world of game development, where each line of code is a brushstroke on the canvas of interactive entertainment. Buckle up for a firsthand look at the hurdles, triumphs, and the creative process that brings a game to life.


The source code for this project is available on my github :




Tanks

The tanks start with a base class called BaseTank.cs, it mostly contains variables that I need both Player and AI tanks to inherit. Both tank types use inheritance and composition to create a single entity.


The way I write my classes


Here's an example of variables I need all the tanks to inherit.

    [Header("----------Components----------")]
    [Tooltip("Where the projectiles will spawn from.")]
    [SerializeField] protected Transform m_ProjectileSpawnPoint;
    [SerializeField] protected Transform m_TurretTransform;

Write most of the member variables like this so they come up in an orderly fashion in the Editor like this and if :


Why I do this :

Although it takes longer to write code, I make sure that myself and anyone else who reads the code understands what each line and variable does.


Imagine this, you work on a game you're on the roll, and for some reason you take a really long break (5-7 days) you come back and now you don't understand what any of that code does, even worse, you didn't leave any comments and now you have to read line by line or complete re-do sections of code that were working fine but were impossible to understand.


The way I write my code goes around this by heavily documenting my process and functionality of code.


I use tooltips for anyone in the editor to know what each variable does without looking at the code. This is useful for game designers and other people who don't really mess with code. I make this a habit, good habits are well...good.


I said I also you composition to make a complete tank, here's an example of the class hierarchy in the inspector for the player tank.


TankVisuals.cs

This class animates visual elements of the tank that don't serve any functionality but I felt the detail is essential for immersion. The Left and right tracks are solid objects with a track texture on them, I take the material and scroll the texture to create a convincing illusion of the tank tracks moving.


TankHealth.cs

This class keeps track of the tanks "health", and armor, these can be replenished with pickups and I didn't want to punish the player for taking a few shells to the body so the health regenerates up to 50% if the player takes serious damage.


TankEngineAudio.cs

TankEngineAudio.cs takes in throttle input from the Tank class and calculates an engine speed (RPM) between Idle and Max RPM, it smoothly interpolates between these values depending on Engine Response and throttle input.

The calulated rpm is them supplied to a third party class called "RealisticEngineSound" that will play the the correct engine sound depending on the supplied RPM. In the future I hope to delve into granular synthesis for engine sounds as it is more realistic and requires less sound assets to work.


Testing & Debugging

After messing about adjusting some values I came up with some good values for the AI and player tanks.


I made use of Unity's Handles to show values I need to know to debug small issues I came across without having to read the console as you can see in the screenshot on the left.


Issues that I came across were the tanks would drive way too fast and crash into each other. I changed Max Torque and response to remedy that but I need to further enhance the AI's navigation.


In the next blog I'll get into the navigation and how I used Unity's NavMesh system to create my own obstacle avoidance and navigation system.

29 views0 comments

Comments


bottom of page