[No coding] Audio

Information
Step 1
In this lesson we're going to be creating audio for our game!
Temp1545091608
Planning
Step 2
Load/Open your project. You should have a moving player and a Render Texture on the UI.
Temp1545207560
Step 3
First we want sound playing from a 3D object. Speakers will do just great! Download any 3D speaker from here.
Step 4
Import a few speakers into your project and place them separately from your player and each other.
Temp1545209727
Step 5
Next find your favorite music online to download from. I recommend soundcloud or download mp3 from youtube.
Temp1545209867

https://soundcloud.com/

Temp1545209897

https://www.youtube.com/

** If you want to download music from youtube, google: "youtube to mp3"

Step 6
Make a Sound/Music folder and import your music into that folder.
Temp1545216442
Step 7
Select your character and Add a Component called "Audio Listener". This will be your "Ears".
Temp1545216564

Important: Every project and Unity game will only have ONE Audio listener, having more than one will cause you to hear a lot of things or infinite audio loops.

(Humans & Animals only have one set of ears)

Step 8
Select any of your speakers and add a component called "Audio source". This means music will come out from here.
Step 9
With the same speaker selected, click and drag your chosen music into the AudioClip space.
Step 10
Next lower the volume because it's loud by default, Change Spatial blend to 3D, and Doppler Level to 0.
  • Volume: Around 0.05 is okay.

  • Spatial Blend: If it's 2D, you can hear the same volume throughout your whole game no matter where you are. If it's 3D then it depends on how far you are from the object.

  • Doppler Level: As you are walking/running, if you have this turned on, the sound will have a dopple(water-like) effect which does not sound right. So turn this off by setting it to 0.

Check Your Work
Step 11
Let's check to see if this works! Hit play, run to the speaker and then run away to hear it fade out. (Use Headphones!!)

You can tell as you walk closer to the speaker it starts to sound louder!

Step 12
Do the same thing for your other speakers and then try walking to all of them. (Use headphones)
Planning
Step 13
If an object has an audio source, then we can only hear when close to that object. But what about world music? (BGM)

For a background music for the world overall, we just need an Audio source on the Hierarchy itself.

Step 14
In the Hierarchy create an Audio Source
Temp1545219113
Step 15
Rename it as "BGM" so that we know what it is.
Step 16
And Just like the others, give it a song to play and give it the same settings, except the Spatial Blend is 2D, not 3D.
Temp1545219520
  • Spatial Blend at 3D: We can hear it louder when we're close to it, and quieter when we are far away from it.

  • Spatial Blend at 2D: Same volume all over the world.

Note: Since this is the BGM, The volume can be either louder or quieter than the volume of the speaker's Audio Source.

Step 17
To test this, let's disable all of the speakers.
Check Your Work
Step 18
Now let's hit play and see if we hear the same music anywhere on the map at the same volume! (Use headphones!)
Step 19
You are finished with this lesson! Click submit and go to the next part on Challenges!
[No coding] Audio Info

Account

MVCode Clubs

Created By

Nepgear tina (instructor)

Course:

[No coding] Unity Intermediate

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach