So, I was supposed to start working on some version control. To be fair, not a lot of work has to be done. I just need to create a Github repository for the project, create a prototype branch, and check in the code. But damn if I’m not getting distracted integrating sounds and music into the game!

SOUNDS EFFECTS

You know, it’s a weird thing regarding sound effects. On all the other Rose of Eternity games I’ve made, I never had to put that much thought into the bread and butter SFX. Menu cursor, confirmation button clicks, etc. It was already in the game, and out of everything I was doing to make those earlier games as custom as possible, those effects (if changeable at all) we’re not on my radar.

Fast forward to today, and well… It’s a thing now. I actually have to implement it. And let me tell you, I had to sit back and think a lot about it. Because I’ve never thought, “Oh yeah, when moving the cursor, it has to sound like this!”. As I said, just not on my radar. I ended up looking up some videos of other RPG’s to get a feeling for what they used, what worked well, what didn’t, etc. I also fired up some stuff that I had on hand.

Since I’m not looking to spend $ on anything during this prototyping phase, I ended up using Fantasy Menu SFX from the Unity asset store. It’s good enough to get me going, and has everything I need at the moment.

MUSIC

Ah, music. If SFX is something I have never given any thought to, music is the complete opposite. I’m always thinking about how to integrate music into my games. Anyone who has played them, or followed this blog for a while knows how important video game music is to me. Hell, I’d list it as one of the main pillars for my games.

One thing that I’ve long wanted to do (I’m talking about since the good old NWN days with Cry The Beloved) is have dynamic music in my games. Not, what they call horizontal dynamic music, where the music changes to another track when something happens in the game, say a combat encounter starts, or you leave a village and enter the forest. Well, I actually do want that as well, but that’s not what I’m talking about.

I’m talking about vertical dynamic music, where you have a track that plays, and then depending on the event, maybe some instruments are added to it, say, percussion. Nintendo has been doing this for years now. Think about the music in some Super Mario 64 water levels, where the music removes some instruments when Mario goes under water, and adds them back when he comes out. Or Super Mario Galaxy during the first Bowser fight, where the longer you fight him, a chorus is added to the music.

One thing that has really inspired me is the music in the 3DS Fire Emblem games. Up until that point, besides a few songs here and there, the music in those games was passable. It wasn’t terrible, but it wasn’t the best. All of a sudden, starting with Fire Emblem: Awakening, it’s like they got a whole new budget or something. The music is absolutely superb, and one of the best parts of it is the dynamic elements to it.

For most levels, there are “calm” and “fire” versions of the songs. “Calm” is when you’re in the menus, selecting what unit you want to move, etc. “Fire” is when an attack/heal/ability/etc. is happening on screen. The way it transitions between the two is magical to behold, and for me, one of the best parts of the game. You better believe that I immediately went out looking for the soundtrack.

Now, their implementation wouldn’t work for me, because all the combat will take place on the board without transitioning to some “attack” cutscene. The switch to the “fire” music would only last 1-2 seconds at most.

No, the way I have figured out to use it is with using the range between allies and enemies. Basically, if anyone is within range of an enemy (or vice versa), the music will change to the “fire” version, and then move back to “calm” when not.

At first, my implementation just didn’t seem right. The music did switch, but it was jarring. It was then that I realized that I needed to smooth the transition out. I needed to slowly fade out the old music, while at the same time, fading in the new music. Functions like the below ended up working out great for me:

     private void TransitionMusic(AudioSource audioSource1Stop, 
                                 AudioSource audioSource2Start) {
        print ("TransitionMusic");
        StartCoroutine (FadeOutMusic (audioSource1Stop));
        StartCoroutine (FadeInMusic (audioSource2Start));
    }

    private IEnumerator FadeInMusic(AudioSource audioSource) {
        float volume = 0.0f;
        while (volume < 1.0f) {
            volume += Time.deltaTime;
            audioSource.volume = volume;
            yield return null;
        }        
    }

    private IEnumerator FadeOutMusic(AudioSource audioSource) {
        float volume = 1.0f;
        while (volume > 0.0f) {
            volume -= Time.deltaTime;
            audioSource.volume = volume;
            yield return null;
        }
    } 

Once I had this in, oh man, that dream I’ve had for, well, 10 years, finally came true. Hearing the music change when getting within range of enemies was awesome.

Add in the other SFX I added, and well, this game is seeming more and more like a game.

Good times.

Till tomorrow…