Question by
patosalas · Sep 01, 2016 at 10:36 AM ·
audiosourcecollider2dinput.touch
play a sound like in a piano when touching a collider2D
Hi guys, I need you to come up with a code (the simplest possible one) to play a note on a collider2D by touching it (it is for android). I have this code to do the same thing but with a mouse.
void OnMouseDown() {
GetComponent<AudioSource>().Play();
}
Is there anything as simple as this? Like a "void ontouchdown" or something?, Thank you all in advance!!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612091956im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Getting nullReferenceException when respawning a gameObject and trying to access the audio source. 0 Answers
Having trouble with melee attack script 1 Answer
Enable BoxCollider2D only on Mouseclick 0 Answers
Platform effector 2d doesn't work with rigidbody 0 Answers
How to kill enemy when the bullet hits the BoxColllider2D? 1 Answer