I want to make bullets make a sound when they come in contact with a wall. I instantiate them as a prefab. I have attached a script to the bullet prefab that makes it explode and destroy itself but it doesn't make a sound. I have an audio source attached to my bullet. I have tried many things but I cant seem to get the sound to play. Here is the code :
`var explosion : Transform;
public var sound : AudioClip;
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag=="Wall"){
audio.PlayOneShot(sound);
Destroy (gameObject);
Instantiate (explosion, transform.position, transform.rotation);
}
else {
audio.PlayOneShot(sound);
Destroy (gameObject);
Instantiate (explosion, transform.position, transform.rotation);
}
'
Your most welcome glad that i could help :) if you have any other problems contact me on my email gto_oni-eyes@hotmail.com
– MC_HALOThis saves me a lot . Thumbs up :D
– epicjosh