Audio Rewritten
I’m very happy this evening after finally coming up with the ideal solution to the audio clipping. I must have rewritten the audio code about 10 times but it has really accelerated my understanding of audio in Unity which is what I was setting out to do. Sometimes you get those moments in coding where you just think, “hang on a minute, there’s a simpler solution to this..”. The problem I faced weeks ago was that I needed to get the impact sounds and play them through the reverb mixer in the shaft section. I realised that I could access the audio clip settings from the collision event but since I was creating audio clips through arrays in custom code it never really worked.
I thought I had cracked it with audio snapshots in transitioning to a heavier reverb sound based on which shaft section the object was in. However since each object was using the same mixer, when a collision happened at the top and the bottom at the same time the transitioning didn’t work and caused horrible unnatural clipping.
I thought that I should instantiate a new mixer somehow so I could play two reverbs at the same time but I’d read about some problems on the forum.
Tonight I have properly addressed the audio situtation by attaching an audioMixer to each shaft section, each with it’s own reverb settings. I then deleted all the custom audio scripts attached to the collectible objects and attached one or more audio sources. Then, on the shaft section I created a script to get all the audio sources attached to the object when a collision occured and then cycled through the audioclips. This creates a completely natural effect.
This meant I was able to delete all the snapshots and clean up the entire script base.
Audio Improvements To Be Completed
- Volume randomization
- Pitch randomization
- Adding proper audio clips
Object Collection / Raycasting
In previous videos you saw that the player was automatically raycasting whenever close to an object with the “Collectible” tag. This was wasting resources and it’s now been rewritten to raycast only when the E key is pressed. Instead of collecting the object into some kind of inventory I wanted the object to float in space and able to be moved around the level. I followed an excellent tutorial by unitylessons.com channel on youtube (https://www.youtube.com/watch?v=runW-mf1UH0)
Here is a new video of the progress with sound:
