- Home /
Question by
Yee1 · Oct 21, 2014 at 11:13 AM ·
playtriggering animation box colliderplayingplays
Getting my 2D sound trigger to play only once
Hi there,
Working on a simple 2D platformer game and I would like a narrator to be triggered when the character moves through a box collider. My problem is that if you move back into that the trigger the sound clip plays again. Ideally the sound clip would be removed after it has completely played through after being triggered once.
#pragma strict
function OnTriggerEnter2D(Collider2D) {
audio.Play();
}
This is attached to a box collider that has an Audio Source. I don't have any programming knowledge so any help would be very much appreciated.
Cheers, Jack
Comment
Answer by SilentSin · Oct 21, 2014 at 11:19 AM
function OnTriggerEnter2D(Collider2D)
{
if (enabled)
{
audio.Play();
enabled = false;
}
}
Your answer
Follow this Question
Related Questions
Play a series of movies one after another 1 Answer
Can't get my sound to work.. 1 Answer
Help : Playing Multiple Background Musics ! 1 Answer
Error BCE0019: 1 Answer
Play a video on a cube 1 Answer