audio source

Hi,

I have an audio source on my main character, walking steps sound which has been dragged into the audioclip and works fine.

I also have these gems objects that I collect and the script for the gems is on my main character and i use the following code for the gem script

  • var gemsound : AudioClip;
    • function Start () {
  • GetComponent.().clip=gemsound;
  • }
      • if (Col.gameObject.tag==“gems”)
  • {
  • Destroy (Col.gameObject);
  • collectablesdata.GetComponent.().gems = collectablesdata.GetComponent.().gems +1;
  • GetComponent.().clip=gemsound;
  • GetComponent.().Play();
  • }

this script works but the sound on the gem sound, sounds distorted or like its conflicting with the main character footstep sound. what i noticed was if i turn down the volume on the audiosource(the one for my main character foot steps) it also affects the volume on the gems…I need to seperate them so i can control both sounds , whats the best way? i’m using unity 5.

Thanks

You should use different AudioSource for effects

do you mean add another audiosource object to my main character (so 2 audiosources on my main character)? and then assign the gem sound to it? i tried that and didnt work, it didnt seem to link and i dont understand why one audiosource component seems to control both sounds.

Don’t assign two AudioSources to the same object. Just create another game object and use it for audio.

i just done that and the audiosource on my gem doesnt do anything but the audiosource on my main character still controls both sounds. Maybe cause the gem script is on my main character?