Hello everyone, I was scratching my head for some time… “why I have to hear my “boing” sound on every brick, I want it only for my paddle!!!”.
So I tried some things, I knew it has something to do with tags BUT… [FAILED]
Search on the forum. [Didn’t find anything]
So… Google is our friend.
So I’ll post my way here, if someone else wants to have more than 1 sound for his/her buncing ball.
First you need to put a tag on your paddle! (Ben told us how to change tags!)
And then the code I changed inside ball.cs
> void OnCollisionEnter2D (Collision2D collision){
> if (hasStarted){
> if (collision.gameObject.tag == "Paddle"){
> GetComponent<AudioSource>().Play();
> }
> }
> }
Hope that will help you have a better sleep and a better BlockBreaker!