x


Need Audio To Stop When I Touch a Game Object.

Hey, I need to stop an audio when another audio turns on, im trying to make ringing and when I touch the phone the ringing stops, how do I do that? Heres part of my script

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.collider.gameObject.tag == "hippo") { hit.collider.audio.clip = myAudioFile; hit.collider.audio.Play(); }

}

more ▼

asked Apr 10 '10 at 04:50 AM

DTJ Productions gravatar image

DTJ Productions
57 19 20 25

is that attached to the player or the phone?

Apr 11 '10 at 06:48 AM Adam Bruns

also is the audio source form the phone?

Apr 11 '10 at 06:48 AM Adam Bruns

The script is attached to the phone, it is in my collision script. Also the audio source is from the phone itself.

Apr 11 '10 at 02:44 PM DTJ Productions
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

http://unity3d.com/support/documentation/ScriptReference/GameObject-audio.html

http://unity3d.com/support/documentation/ScriptReference/AudioSource.html

http://unity3d.com/support/documentation/Components/class-AudioSource.html

http://unity3d.com/support/documentation/Manual/Using%20Components.html

Between these reference articles and a use of triggers/colliders, you should be able to detect when a collision happens, access the necessary Audio Source Components, and control them as needed.

more ▼

answered Apr 10 '10 at 09:13 AM

Design3.com gravatar image

Design3.com
640 1 1 10

Thanks for these references but these don't help, I need a script.

Apr 11 '10 at 02:48 PM DTJ Productions

in other words: Please use the documentation and stop asking people to do your work for you :p ... No really, DTJ, if you find the documentation hard to work with, please let us know how we can improve it.

Apr 14 '10 at 11:16 AM Nicolaj Schweitz ♦♦
(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:

x3465
x1031
x527

asked: Apr 10 '10 at 04:50 AM

Seen: 2920 times

Last Updated: Apr 10 '10 at 04:50 AM