if touch a game object play a sound

Hi. I am new to programming but years ago I learned basic things of unity. I am trying to make a small xylophone for mobiles and what I try to do is that when you play a key of the xylophone the note sounds. the problem is that I don’t get how to do it …

I managed to make a note with Input.getkeydown sound when I press a key on the keyboard but I don’t know how to do it on mobile screens \ tablets

I just found a solution by making the keys as buttons. not like sprites but if someone has another way to do it I would like to listen to it and learn: 3

Buttons are a good way to do it. You could do it with sprites by using Camera.main.ScreenToWorldPoint, and comparing the position hit to your sprites. But buttons do all this for you.

1 Like