- Home /
How to play an audio one shot clip on a collision
I have a fps shooter game and all the shooting and stuff is works, but my problem is that my player shoots glass ballish things and I need to know how to make it so when the ball collides with something it plays a audio clip.Please Help.
Answer by aldonaletto · Apr 28, 2012 at 02:38 AM
As @Lo0NuhtiK said, you could use OnCollisionEnter to detect the collision and play the sound. If the ball is destroyed when colliding, you can use PlayClipAtPoint:
var sound: AudioClip;
function OnCollisionEnter(col: Collision){ // create temporary AudioSource and play the sound: AudioSource.PlayClipAtPoint(sound, transform.position); Destroy(gameObject); // suicide ball }
Your answer
Follow this Question
Related Questions
help sound on collision when key down 2 Answers
How to emit a sound on specific collision. 1 Answer
Play audio on keyboard click? 1 Answer
How to create sound on keyboard button? 1 Answer
How to play loop an audio clip on button hold down? 3 Answers