Quick question about music

I was following along in the Unity Game Development Essential Book and one part was not working for me. When it came to putting sound in my scene the book said to put a audio source component on the terrain and from there select the file to play. I did this but my scene never played any sound and I saw no errors.

However if i create an empty game object and attach my audio source to that, then the sound works. Could someone give me any explanation on why this won’t work attached to the terrain?

Thanks in advance!

When attached to the terrain the audio source is active, set to play on awake, and loop.

Not sure why this is happening, just leave it on an empty game object.

Also when I put music on something other than the character and you move the character around fast, the sound may get distorted. So whenever I have background music I apply an audio source to the main character, or the main camera…something that moves with the player.

Attaching it to the camera works perfectly thanks.

You might also try importing the music audio clip with ‘3D Sound’ set to off; this should disable panning and volume attenuation for that sound. (It’s possible that the reason you didn’t hear it when it was attached to the terrain was simply that it was too far away from the listener.)