sound not loading C#

Hi guys,

I can’t seem to get my sound to play? I can see it’s loaded when the game plays but it won’t actually play, any ideas?

private AudioClip mySound;
	void Start(){
		

		  audio.clip = (AudioClip)Resources.Load("mySound");
		  audio.PlayOneShot(mySound);

	}

to play audio in C# use nameOfAudioClip.Play();

so for you mySound.Play();

Thanks dudes,

I ended up using the following, simple, but true :confused:

private AudioClip soundthing;
	void Start(){
		  audio.clip = (AudioClip)Resources.Load("soundthing");
		  audio.Play();

	}

Keep up the amazing help guys! :wink:

Assume won’t play means you cannot hear it?
Check the Audio Listener is close enough to source.
Check the roll off of the sound based on distance.

Hi FlashX!

I would do this instead:

//Simply Drag and drop your Sound in this var

public AudioClip mySound;

void Start()
{
    //Forget About looking in ressources...
	audio.PlayOneShot (mySound);
}

PS: you wanted to store “mySound” in audio.clip and won’t use it after…

I know you can search GameObjects with GameObject.Find(“”) and even component and scripts, but I never search for a sound and I looked for an alternative way and found nothing… When you get stuck, try a different way!

Math