Audio controllers

Apparently the best way to control background music (BGM) and sound effects (SFX) was to create global booleans to be checked to play sounds. I reverted the original change from using the AudioListener.PlayClipAtPoint() static function and calling an if everytime to changing the original playR() function into a new playBGM() and playSFX() function, along with a new RandomSound_Mech, to check with the global boolean.

A6yog want to play background music randomly from an array of AudioClips, and that is fine (and better, since it will get boring without the shuffling), so I needed something to keep the state of the BGM, along with the ability to wait for the music to complete playing before switching to another track. That is easily solved with a coroutine and a play boolean to check if it is playing. (might change to audio.isplaying later)

As for the SFX, I used the original formula and this time made all calls to music use the special playSFX() function so everything can be controlled for the main object.

Looking back now, I somehow can’t imagine what would have happened if I have written the whole thing in JS (which I will never ever wanted to do), and/or under duress of a foreign API, C-sharp. Unless of course the C sharp code is formatted nicely, and things like list generators, for loops (not C style) exist.

Unfortunately it doesn’t, so I guess it might be hell for me next week when I focus on the networking. :P

 
0
Kudos
 
0
Kudos

Now read this

Colliders Everywhere

Somehow this became the best solution to jumping, along with other pleasant surprises. While I was solving the problem of jumping, I couldn’t get a working solution of getting the zoid to jump only when it is on the ground, which... Continue →