Wednesday, 15 May 2013

Runes: Songs of the Gods - Version 0.6

Version 0.6 – Adding more Sound Effects, Score and Bonus score system and GUI functionality

In this build I wanted to get the following done and out the way:
  • Implement the Score system
  • Implement the GUI functionality (a timer and score markers)
  • Find a font to use
  • Adding various sound effects:
    • The Rumble effect once the runes are all selected and the Wobble “animation” plays
    • The tingle sound once the Score particles start up
    • Loop the wind sound seamlessly
    • Add the “Gods Sing” tracks to the game and play them once the bonus is activated

As a side-note, as I mentioned earlier the matchmaking had a bug and the array desynced from player actions. So what the player saw wasn’t actually mapped to the data structure and therefore not the game logic. This didn’t seem like a very serious bug back then but as the game became more and more polished these bugs started looking more and more ugly. Especially since my design was kind of going along as I implemented things. I knew this would lead to spaghetti-code down the road and it seem like it was drawing nearer.

Players would often match runes only to have them not match up at all or add to a score. At times they would mismatch them and a score would be added. Because the array was locked to three values but the players selection wasn’t  the player could end up selecting all of the runes. The array added the first 3 then desycned and the player had to wait for all runes to deselect and array to clear before they could start again. So essentially playing the game to fast would completely break it. Not good for a speed based game.

Anyhow more on that later. For now in this build I started adding the score system and after it was up and running I added a bonus score in line with my new design. I also added a simple timer to the game to add a sense of urgency. All the elements worked fine and I made a new GUIManager class (GUIManager script) to handle drawing the GUI values on the screen. For some reason I thought yellow text was a good idea … urgh.

I added a neat celtic themed font. I did this using the inspector and a GUI style. I tried doing this by code during runtime but it really wasn’t necessary so I left it.

The way I was managing the sound in the game was similar to the GUIManager called (amazingly enough) SoundManager! All the sounds were stored in this script locally with a bunch of get methods.

The actual audio files were all added to the games main camera with AudioSources. Once the SoundManager scrip initialised it went and got the audio sources and stored them for later use:

    void Start () {
        Asources = gameObject.GetComponents<AudioSource>();

        windLoop = Asources[0];
        IntroTalk = Asources[1];
        RockSound = Asources[2];
        ChimeSound = Asources[3];
        GodSing_One = Asources[4];
        GodSing_Two = Asources[5];
        GodSing_Three = Asources[6];

Easy to maintain and easy to manage. :D

The next part – adding the “rumble” sound effect probably took my 80% of the time to get working in this build. I edited it from a giant rock scraping audiotrack (I was allowed to edit it according to the license, the people on and the site itself are amazing and I can't thank them enough).

Once edited to a bite sized little rumble I tried to get it into the game. What in design looked like a simple thing turned into a major hassle. At first the rumble sound effect would only start playing once the runes were done with their rumble effect. At first I thought this was caused by where I was placing the Play Sound call. Which was indeed part of the problem.

Because I was using the Update() function that runs once a frame the sound was playing over and over again every frame. Which meant that it would only play once the iteration was done (meaning Update() stopped saying PLAY SOUND PLAY SOUND PLAY SOUND PLAY SOUND).

So this meant once the final rune was done rumbling, Update() let it go and the sound finally played. To fix this (and I used this method a few more times when working with that damn Update() function) I added a toggle. A simple Boolean toggle:

    void PlayActiveSound(){
        if(ToggleSound == true){
            ToggleSound = false;

This means that even though Update() keeps calling this function it won’t play more than once (depending on how you set ToggleSound). Because I’m a slow boy that took me about 3 hours to figure out so I was happy to move on to more simple problems. I added the tingle sound effect next, which was pretty easy. I just called it once the particle effect was spawned and played it once.

Next up I added the wind loop after making it seemless in Audacity. It still didn’t play seamlessly in the Unity editor or builds though. This is still a problem and I will still need to solve this to make the wind audio final. For now however the wind audio looped at least.

Finally I added the God Sings tracks and made them play. I did this at different thresholds that I simply hardcoded into the RndRune class. The bonus score was being done in RuneSaver and the Sounds were being played in RndRune. This is a no-no! I should have made a new class for Scores but I did not think scores would become so complicated.

    //Yay first time run and it works lol
    void GetGodSound(){
        switch (runesaver.getScore()){
            case 5:
            case 15:
            case 20:
                Debug.Log("No Case Reached in GetGodSound");

So to summarise:
  • I added a score system and reflected the score and bonus score in the GUI.
  • I added a custom font asset and used it in the GUI
  • I added most of the games audio effects but couldn’t get the wind sound to loop seamlessly outside of audacity

No comments:

Post a Comment