- Home /
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(); }
}
The script is attached to the phone, it is in my collision script. Also the audio source is from the phone itself.
Answer by Design3.com · Apr 10, 2010 at 09:13 AM
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.
Thanks for these references but these don't help, I need a script.
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.
Your answer
Follow this Question
Related Questions
Stop audiosource clip from playing 1 Answer
Adjusting system audio levels... Please help! 1 Answer
Timer Scripting No Idea On Script 0 Answers
play sound when moving stop sound when not 1 Answer
Audio Needs to stop 1 Answer