Cyber Commando: Devblog 4:Refactor Aiming
- Jack Leatherbarrow
- Nov 8, 2023
- 1 min read
Updated: Nov 24, 2023
While playing through some of the mechanics I've made so far, I found that the current weapon system was a bit messy and not suitable to be able to add other weapon types easily. The first way I was checking which weapon was equipped by multiple branches of is this equipped and if not equipped etc. it was getting messy and hard to read.
After some research and experimentation, I found a system that would be much better suited, neat, and easy to read/ implement new weapons without too much trouble. To achieve this I made an E-Num to represent each weapon, then i set the enum to two variable types. Target weapon and Current weapon.

The code above demonstrates the logic behind it. it first checks if the weapon itself is equipped, then if it is equipped the animation for holstering the weapon will play. if not, it will set the target weapon to a new weapon put the existing weapon away then equip the new weapon

This allows me to add as many weapon types as needed without needing huge changes to the code.
Comments