- Home /
Sound on collision
I've looked up tons of scirpts for this but none of them really helped or made sence. Just simply trying to make a sound play when you hit an item
the i tried:
function OnTriggerEnter( otherObject: Collider ){
if(otherObject.gameObject.tag == "Player"){
audio.clip = otherClip;
audio.Play();
}
}
It works, but the problem is when i try to put Destroy(gameObject) anywhere in the script it either doesn't destroy but plays sound, or vice versa. What should i do. Thanks :D
Answer by runevision · Sep 22, 2010 at 08:30 AM
You can use AudioSource.PlayClipAtPoint()
This will play the sound without it being attached to a specific AudioSource component on a GameObject, so it won't stop playing when the GameObject is destroyed.
Your answer
Follow this Question
Related Questions
Animation + sound on collision 1 Answer
Alternate between two Audio clips on collision 3 Answers
Sound on collisions 1 Answer
help sound on collision when key down 2 Answers
Change Audio source on collision 1 Answer