- Home /
Question by
Onionvision · Jul 26, 2012 at 06:29 PM ·
gamesoundsoundshorror
How to reproduce a sound on collision?
Hi everyone...i wanna know how to reproduce a sound on collision with an invisible mesh. Is this possible? Bye
Comment
Answer by Screenhog · Jul 26, 2012 at 06:41 PM
This shows how to play a sound, and how to change the sound that is being played: http://docs.unity3d.com/Documentation/ScriptReference/AudioSource-clip.html
You'll want something like this:
function OnCollisionEnter (collision: Collision) {
collision.gameObject.audio.Play();
}
That will make the object you collided with play the specified sound.