Finalizing the weapons
|
Continuing off of last week’s post, I’m going to talk about the various changes and additions I’ve made to the weapon system and how I’ve just about finalized it. ANIMATION This week my artists sketched up the final weapon that was implemented into the game and also added animations for all the guns. Adding them to the weapons themselves was fairly easy. I coded in the base weapon that whenever the player fires a shot, it would trigger an animation event on the weapon. I exposed the trigger name as a public variable, allowing me to simply adjust the animation name from the Unity Editor instead of having to manually implement it for each weapon. This is not so much animation, but I’d say it tacks on. I decided to add recoil to the weapons whenever they fire. Currently it works on the principle of making a randomized vector every time the gun fires and sets a recoil-smoothness float which I use a Lerp to adjust the position of the gun between it’s original position and the original position + random recoil offset. The Lerp float reduces in to 0 over-time at an adjustable speed. With that in mind, in order to finer tune the recoil, I exposed the Minimum recoil, Maximum recoil and Recoil recovery speed as exposed variables. AUDIO One of the most glaring issues I immediately noticed was that the firing sound got cut off every single time you started playing it. This is because 1 entity cannot seem to emit more than 1 sound at the same time. So as an alternative, what I did was create a temporary audio entity at the current location of the entity spawning it and modify it as I pleased, which solved the issue of sound stacking. FINALIZING One of the final issues I noticed was that the bullets didn’t always come out of the end of the gun. This was due to the fact that each gun has it’s own size and I can’t always make sure that the bullets come out the same part of the sprite, since this isn’t a 3D model with attachment points. So, as an alternative, I made a code-relative attachment point for the guns and exposed them as public variables, so the creation point of the bullets can be adjusted through the Unity Editor for each weapon. |