Hi JohnB. I also noticed that the “boing” sound was playing on every collision the ball made. So I set out to right this. In the OnCollisionEnter2D method in Ball.cs, I began to look at the properties of the passed in collision. I noticed that collision.gameObject returns the colliding object. So with that in mind, I put an if block to see if the ball is colliding with the paddle object:
Also, I wouldn’t keep using GetComponent calls in each collision. If you know there are going to be multiple collisions, which we do (unless the player is utterly useless I suppose), we can assume that the paddle will have the need for this component reference multiple times, so, to slightly improve performance, use a private variable to store a reference to the AudioSource and populate it once within the Awake method. Then use the private variable within the OnCollisionEnter2D method to play the clip.
So, @Paul_Mac, if your variable audio is private and populated in this way, I’d say you’re spot on.