Search Unity

How to play a sound.

Discussion in 'Audio & Video' started by Noah492, Jun 21, 2015.

  1. Noah492

    Noah492

    Joined:
    Jul 2, 2014
    Posts:
    44
    I don't quite get what to do with the audio source and playing it with my script. I want it to play when the timer ends. Any idea?
    upload_2015-6-20_22-57-52.png
    Code.
    upload_2015-6-20_22-58-24.png
    Attached.

    I don't get it. Any help is appreciated! ☺☻☺☻☺
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    if (time <= 0) keeps being true every frame after a while.

    So play() is called every frame, so you don't get to hear it. Change your code so that Play() is called only once.
     
  3. Noah492

    Noah492

    Joined:
    Jul 2, 2014
    Posts:
    44
    Ah, thank you so much! Now it plays every frame which sounds really funny but it worked!