When we started working on HexWorld none of us really knew what we would end up doing for the project as we’d never done something like it before. Over the course of the project our roles would become more defined instead of everyone being “General Programmer”.
Towards the end of the project my roles had moved into the UI and Sound categories. With Unity, or at least the version we were using creating a menu system and a sound management system seemed like a fairly simple thing however as time went on I encountered some rather unusual issues with creating both.
For the UI of HexWorld I needed to create the management system and art. With the artwork I kept it fairly simple with pixel art images created in Paint.net that I then adjusted inside of Photoshop. Below I have included images of some of the artwork:
The problems when creating the UI lay in the management system, the whole system was supposed to use Unity’s inbuilt event system. As time went on the whole system started to act rather strangely with one of the largest problems being dropped input when dealing with controllers, and broken function calls (despite what was being told to me by Unity). After trying to fix these issues for a long time it was decided that it would be easier to just make my own simple event system.
In creating this simple event system as a proof of concept a selection of switch statements was created that would manage the different layers of menus that existed. This worked first time with no serious issue surprisingly, the only real issue with it was that it couldn’t be changed for the finals of the Imagine cup due to University work. If I had the time to change it I would have likely used a state machine to make expanding it much easier.
As I was the only person in the group with any experience editing audio files (worked with a friends band as general “Sound Guy”) I volunteered to try and bring some audio to the game. The sound effects themselves were created using open source tracks and a lot of editing inside Audacity to get the right sound which you will be able to find some of here (the jump pad is mine and Riccardo’s favorite, and also took way to long).
The actual manager of the audio changed in approach a few times during development. Originally it started life as adding audio sources by hand to the objects that will create them. This approach quickly proved to be terrible especially when we realized all of the hexagonal tiles would require there own audio source.
After scrapping this manual method an automatic manager was created. This manger was designed as a fire and forget tool that would take in information of the object producing audio, and the audio to be produced. The manager would then bind an audio object to the producing object with the correct sound file attached and then pass a reference to the producing object that linked to the audio object. The audio objects themselves would clean themselves up if no sound was playing from them for a period of 0.5 seconds. When tested this method proved to be very effective and pats on the back were given before we firmly slammed into a wall and everything broke again.
The reason everything broke was due to the sheer number of audio sources that were being created in one of our test scenes. As it turns out you can’t just expect to have an unlimited supply with no issues. When in the test scene over 1000 audio objects needed to be added to the scene which as it turns out exceeds the maximum number of audio objects supported by Unity…….on that system. As it turns out there isn’t a set amount supported as it’s system dependent and there is no way of finding that number (or at least no way I could find) without breaking it.
After testing on multiple systems we found 500 to be a safe number of audio sources. With this new safe number intact I changed the system to never exceed that upper limit with over half of the limit being separated for tile movement. In order to ensure that only the tile closest to the player would play audio a simple distance check was created that would run before the assigning of audio sources that would cancel if they were too far away.
There is more of my work in HexWorld than what is above however it is hidden among other team members code or I have just forgotten that I had written it. If you would like to see an example of any of the code I have talked about feel free to contact me.