Playtesting

For playtesting, you will need to get a few assets from the Unity Asset Store for the sound effects, background music, and atmospheric sounds. These are the ones I recommend that you use for this example:

First, create an empty GameObject, name it RunningSource, and add an audio source to it; this can be done by navigating to Add Component | Audio | AudioSource. On the main camera, add AudioSource if there is none. Next, add the SFX_Manager script to the camera. For its values, set the following:

  • SFX volume to 1
  • Run to footsteps_runcarpet_1
  • Spell to shot_hand_gun
  • Strike to whoosh_power_fist
  • Run Source to the RunningSource GameObject

Now open the SFX_Manager script and add the Update function:

public void Update()
{
  if(Input.GetKey(KeyCode.W))
    pRun();
    
  if(Input.GetButtonUp("Fire1"))
    pStrike();

  if(Input.GetButtonUp("Fire2"))
    pSpell();
}

When you test the scene, you can click on the left mouse button to play the strike sound effect. Clicking on the right mouse button will play the spell sound effect. Then, finally, pressing the W key will play the running sound effect.

To playtest the atmospheric sounds, a new empty GameObject will need to be created; name it AtmSource and be sure to add AudioSource and the ATM_Manager script to it as well. Set the values of the script to the following:

  • Tmp List size to 1
  • Element 0 of Tmp List to RainLoop1 – 29 Seconds
  • Keys size to 1
  • Keys Element 0 to Rain
  • Atm Volume to 0.75

Lastly, add this line of code to the end of the Start function in the ATM_Manager script:

PlayRepeat(atmListt[0].Key);

Now, when you test the scene, you will hear the rain sound effect playing as expected. The final part to test is the background music, which will be similar to the way we tested the atmospheric sounds. First, create a new empty GameObject, name it BGMusicSource, and add AudioSource and BG_Music_Manager to it. We will set most of the script's values to their default values except these two:

  • Song List size to 1
  • Song List Element 0 to maintheme_1_the_combat_collection

Now, in the BG_Music_Manager script, add this line of code at the end of the Start function:

PlayRepeat(SongList[0]);

When you test the scene now, you should hear everything that we added so far. The background music and the atmospheric sound effect will play, and if you click on the left mouse button or press the W key, your sound effects will play as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.140.204