
Concept
This prototype project started as an exercise to myself to improve my C# skills.
​
I also wished to experiment with a more faithfull adaptation of tank movement taking inspiration from how tanks actually work rather than the old-school control scheme from the era of D-pads.
​
The goal of this prototype was to experiment and iterate on tank controlls as a concept while also improving my C# compitency.
​
I have made everything in this prototype myself, from the spawnining of trees and rocks on the map to the turret barrel pitch being handled independently from the turret rotation itself.
​
Further development will see me add AI tanks to fight the player. But as of writing, we are not there yet.

Faithful Tank Controls
Iterate on established old-school tank controllst in the name of realism

Traditional tank controls don't allow for independent track movement.
This became the focus of my design as I wished to repplicate the feeling of sitting in the driver seat of an old tank, two levers in front of you and shifting each tracks gear up or down by pulling the respective lever forwards or backwards.
​
The prototype therefore doesn't use the standard WASD control scheme and instead use a QAED scheme.
Q and A control the left tank track and E and D control the right.
Each tracks gear is managed in that tracks respective instance of a gear script as can be seen in the provided snippet.
Pressing Q or E would increase their respecting tracks gear by 1 on a scale from -2 to 2, pressing A or D would decreese it. The tracks current gear is visiulized on the back of the turret.
Independent Tracks


I'm using wheel colliders for the tanks movement since they allow me to easily control the speed of the weels while also containing suspention functionallity.
​
Before I used wheel colliders I was adding force at the tracks position. I moved away from this approach since I had no good way to control the ammount of force while still having the tank drive at a reasonable speed.
​
​This unique gear system leads to a interesting driving experience since the player is not making an active effort to drive the tank, instead the player just adjusts the tanks course as the tank will continue to move forward for as long as it is in a positive gear.
​
It's not the easiest thing to drive, nor do I think it should it be. It's deffinetly a foreign experience but one im confident a game could be centred arround.

Turret Yaw Rotation
Most tanks have turrets that rotate in order for it's gun find it's target. I want one.
Initially the turret roted at the same speed the player was looking arround, this was quite frankly ugly and way too arcady for the "realistic" feel I wished for the tank as a whole.
This is easily solved with some interpolation, estimating a rotation value that fall between the rotation to desired target and current rotation. This slows down the rotation towards the desired target and makes for a much more belivable experience.
Just to be sure that I dont acidentaly manipulate the roll and pitch values of the turret rotation (this could happen if the tank were to fall over), I decided to project it's rotation onto a plane to realy lock it in plane of rotation being tied to the tanks up normalized vector.

Barrel Pitch Rotation
Since the whole turret shouldn't nod if the camera is looking up or down I need to handle the barrels pitch rotation independently from the turret itself. This proved difficult and I could not get it working for the life of me. Initially I tried projecting the barrel to a plane also, one going vertically this time. It kind of worked, but the barrel was always bending a bit to the right or left. Furthermore I wanted to define the turrets max depression and elevation angles.
Many hours of Unity documentation later led me to find the Atan2 function, paired with the Rad2Deg, it now returns the angle value needed for the pitch. IT WORKS!


Shooting & Recoil

A working gun should fire. As is, when i the Fire() function is called, I Instantiate a shell of wich type is randomized from an array consisting of:
-
High Explosive
-
Smoke
-
Armor Piercing
This gives me no control of wich shell type is fired.
​
Improvements on this system would see me adding a "Loader" module for the player to be able to select wich type of shell would be fired the next time the trigger is pulled.
After this point the gun will look at the fired shells recoil value and apply force at location towards a "recoilpoints" backwards normalized vector based on mentioned recoil value. This setup realy makes the suspention on the wheel colliders shine.


This prototype has been a great exersice and not only helped me in self confidence in redards to non-blueprint scripting but activley bolsterd my knowlage of C#, sepperation of concerns and propper data structure.
​
The disecting of the tank into smaller more comprehensive modules have been key in debugging this larger system. However my work does not stop there, i will continue to work and improve upon these priciples in this project and more projects to come.
​
Designing the tanks movement system has been fun and insightfull, seeing playtesters initially struggle with the QAED control scheme to later get used to it and start driving around somewhat effortlessly proves that we are not always tied to the conventional WASD layout and successfull iteration is possible should one be willing to take some risks and apply sparingly.
​
Unity is a treat to work in and im looking forward to spending more time within the this engine, professionally or otherwise. Continuing to improve my upon my technical skills.
