Search Unity

Help with sound script please!

Discussion in 'Scripting' started by Mikenekro, May 11, 2014.

  1. Mikenekro

    Mikenekro

    Joined:
    May 11, 2014
    Posts:
    21
    My audio clip was working just fine yesterday. Today I load my scene and the audio has stopped working. I checked everything and it was all the same. The listener is checked, the audio source is there and checked, the code has not been changed and for some reason it will not play.

    I have it set up so the audio plays when the player clicks the space bar, a jumping sound, the audio plays one time for 1st jump and 1 time for 2nd jump then stops.

    For some reason it has stopped working.
    Does anybody know what this might be?

    Here is the script that I use to play the audio

    Code (csharp):
    1. void Update ()
    2.     {
    3.         if ((grounded || !doubleJump)  Input.GetKeyDown (KeyCode.Space))
    4.         {
    5.             anim.SetBool ("Ground", false);
    6.             rigidbody2D.AddForce (new Vector2(0, jumpForce));
    7.             audio.Play();
    8.  
    9.  
    10.             if(!doubleJump  !grounded)
    11.                 doubleJump = true;
    12.  
    13.  
    14.         }
    15.  
    16.  
    17.     }
     
  2. Mikenekro

    Mikenekro

    Joined:
    May 11, 2014
    Posts:
    21
    Fixed it again lol. Nothing to do with the script. Just went to edit, project settings, audio then it started working for some reason.

    Not sure what happened but it would be nice to know for future purposes.