Weapons in a Cube was a project developed by me in Unity/C# to explore flexible weapon system structures and unique weapon abilities in video games.
Inspired by the weapon design of various games such as Team Fortress 2, Borderlands, and Destiny 2.
I designed and developed this entire project.
There are currently 4 weapons:
Personal Space - Explosive pistol that increases in blast radius and damage the further you are from the target. Weak close range.
Tangential - Rocket/Grenade launcher that does exponentially more damage (with a damage cap) the further the enemy is away from the center of the blast radius. Direct hits are weak.
Ping Pong - A hit scan weapon that triggers an explosion on a headshot/precision kill. The explosion affects other enemies and primes them to explode shortly after, this effect chains explosions for a number of iterations.
Upfront Notification - A hit scan weapon that launches the opponent in the air after two successful hits. Enemies affected by this effect receive increased damage.
This project is a tech demo and focused heavily on the technical side. Visual effects are minimal and each weapon has a placeholder model. Weapon explosions are visualized with a red sphere.
The weapon system consists of a central script that changes values depending on what weapon is equipped. This central script handles the fire input from the player and helps keep things organized.
Special weapon effects are handled on separate scripts that are called from the central script. This is organized as such to not bloat the central weapon file and to organize everything clearly.
Some of the weapons were deceptively harder to program than first anticipated. Most notably Upfront Notification and Ping Pong.
Upfront notification was a bit more difficult because of how the weapon kept track of which target it hit twice. At first I made it so that a hit would increase the effect condition by one (the effect is triggered after two hits). This was a problem since you can hit an enemy once and then hit another one to trigger the effect which was not intended. To solve this, I needed to store which enemy the player hit and reset the effect condition back to zero if you hit another target.
Ping Pong was especially difficult because at first the explosion function was called by each affected enemy at the same time. This resulted in duplicate explosions intersecting with each other. To fix this I instead added the affected enemies in a list and called the explosion function in a loop for each enemy. I also added in checks to make sure that the explosion won’t affect the same enemy again.