x


Play and stop sound using OnTrigger

Hi, Help me please: I want to play audio when entering a trigger and stop playing when you leave the trigger. Thank you very much

var Sound:AudioClip;

function OnTriggerEnter () {
    audio.PlayOneShot(Sound);
}
function OnTriggerExit () {
    ???????????????????;
}
more ▼

asked Oct 28 '11 at 05:36 AM

richard.falcos gravatar image

richard.falcos
16 7 13 17

Duplicate entry- please delete this one.

Oct 28 '11 at 04:58 AM syclamoth
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I haven't tried it myself yet, but a quick google search turns this up right in the handy-dandy documentation: http://unity3d.com/support/documentation/ScriptReference/AudioSource.html

Did you try: audio.Stop(); ?

more ▼

answered Oct 31 '11 at 06:29 PM

MattWhiting gravatar image

MattWhiting
1 2 2 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x38

asked: Oct 28 '11 at 05:36 AM

Seen: 548 times

Last Updated: Oct 31 '11 at 06:29 PM