audio.play()

Im having a weird issue with Audio. I have a trigger set up that plays a metal clank when you step on it. You walk over it and it goes clank once and springs the trap. This always works the first time. When you die you get set back to a check point and the trap gets reset. The second time I Trigger the trap the audio will not play, In fact no matter what I do I cant get the audio to play. even using a bool and update and turning it on in inspector it simply will not play.

Anyone else have this issue? found a resolution?

When you set back to the checkpoint the scene is reloading?
In your script how u call the audio to play?
Can you be more specific please ?

Lets say for instance we have a

var triggered : Boolean = false;

function OnCollisionEnter2D(col : Collision2D)
{
     if (col.gameObject.tag == "Player")
    {
        if(triggered == false)
        {
            audio.play();
            triggered = true;
        }
    }
}

Then in another object we have a script that detects collision with player and kills him that sets triggered back to false (which is working perfectly) When I trigger it again and set the trap loose it will not play the audio. Even if I trigger bool over and over.

I have even tried loading the clip into AudioClip and PlayOneShot(name); still doesn’t play a second time.

The scene does not reload you are simply Instatiated to a playerSpawner object

if you are sure that collisions are working then you have to make these steps:

  • from your scene choose the obj with the Audiosource so you can see it at the inpector
  • run the game
  • the 2nd time the trap is triggered keep your eye at the Audiosource (Inspector)
  • is the Audiosource AudioClip filled with your sound clip?
  • is Audiosource muted or not?
  • is Audiosource volume = 1 ?
  • is Audiosource “Play On Awake” false?

but first be sure if collisions are working…
http://forum.unity3d.com/threads/211426-OnTriggerExit2D-not-working-when-changing-local-scale
http://forum.unity3d.com/threads/211549-2D-Physics-Collisions-Triggers

the easiest way is always the solution to the most of the problems