Ok, here’s what I’ve done I’ve made a boing sound only play when it hits the paddle/bat/ship. The way I did that was to use a game tag on the whatever you call it like in my case “myBat”. This sound is the attached AudioSource. Then on the “Breakable” objects ie the bricks use the playAtClipPoint with the overloaded volume control,so, it doesn’t blow my ears out . This sound was attached programmatically as per the lecture.
For a different sound when the bricks are destroyed, I’ve used a sound on the “smoke” prefabs that we make in a couple of lectures from now. That way you can have a different sound on that as well. Haven’t changed all of them yet in case a better way turns up - I have a question pending on the forum and hoping that someone answers it.
if (hasLaunched)
{
if (coll.gameObject.tag == "myBat")
{
float distanceX=(this.transform.position.x -
myPaddle.transform.position.x);
Debug.Log("Batter Up: "+distanceX);
audio.Play ();
}
if(coll.gameObject.tag == "Breakable")
{
AudioSource.PlayClipAtPoint(brickHit ,transform.position, .2f);
}
}//*/
Now that’s probably as clear as mud - and my brain has turned to mush from the different ways sound are attached to scripts and object and how you play them , that I need a good lie down .
If you need more information then ask away and I’ll try and help. Remember I’m pretty much a noob with Unity with this course being my only structured learning.