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:
1
footsteps_runcarpet_1
shot_hand_gun
whoosh_power_fist
RunningSource
GameObjectNow 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:
1
RainLoop1 – 29 Seconds
1
Rain
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:
1
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.
18.118.140.204