Sword Fun
Once the staff worked, I started work on the sword. The sword does damage using a
trigger collider which is the same shape as the swipe VFX. Once something enters the
trigger, it checks if the point of entry is inside a "sweep angle" and if it is,
damage is applied to the object. I found that there were issues with this system, but
these could be easily fixed. The primary issue was the swipe causing multiple hits
if the object re-entered the trigger. This was easily solved though using a list of
gameobjects and checking if the object that entered the trigger has already been hit.
Part of the damage system is the data that can be transfered to the hit object. It
contains the object that delt the damage (sup as a projectile), the object that the
originally started the attack (the player/enemy), the target (the object that is hit),
the position of the attack (useful for VFX spawning and physics), the normal of the
attack (for setting the direction of VFX and force), and the damage value. I use these
variables for applying forces to the boxing bag in the garden, and they could be used
for special weapons such as those with life-steal.
Thanks to how I've built the inventory system, the player and the enemies can both use the same weapons and inventory systems. We wont want the enemies using the exact same weapons because of balancing but the option is there.
Audio Triggers
Audio sources in Unity are good for playing single sounds but when you have multiple clips of the same sound, it's good to have an easy alternative in place. I solved this by creating audio triggers and "sounds" which are scriptable objects with a list of audio clips and some extra settings like min/max pitch.
I made multiple components that all have different funtions. One just plays a sound, one plays multiple sounds, one spawns a new audio source (for objects that are destroyed and need to play a sound), and one for playing a sound globally.
I enjoyed making icons for the triggers (the audio speaker icon with a lightning bolt)
as I would like to use this system in future games as it removes the need to
constantly typeaudioSource.clip = clips[Random.Range(0, clips.Length)];
Test Day
We hosted an event to test the game before the main release on the 27th (May). It was
really fun but it didn't come without it's problems; the animations broke an hour
before the event was starting, the temporary portals were spawning in every room, and
the skeleton enemies weren't working.
Luckily, all these issues were fixed and the day continued with good review and some
bugs for me and the other programmer to fix. Once I got home, I spend a few hours
fixing most of the bugs that cropped up and added some extra features that some players
recommended.
A Few More Fixes...
I made a bunch of changes before the submission to get the game into a state where anyone can load it and be able to play. I also fixed some bugs that I didn't have time to do the first commit and added the rest of the sounds to the project.