I have 2 2D gameobjects in unity.I want to achieve next but only with Input.GetTouch for android:
- When i click on first or second object---play some sound.
- When drag any of those game objets to each other combine them to one---without playing sound from first case.
- Then be able to click on this combined object---without playing sound from first case
Problem is because I dont want to play sound from first case if object is dragging. I already tried some code with couroutine but it doesnt work:
if (Input.touchCount > 0) {
touch = Input.GetTouch(0);
touchPos = Camera.main.ScreenToWorldPoint(touch.position);
RaycastHit2D hit = Physics2D.Raycast(touchPos, Camera.main.transform.forward);
switch (touch.phase) {
case TouchPhase.Began:
samoKlik = true;
if (samoKlik) {
StartCoroutine(korotinaKlika());
}
}
case TouchPhase.Moved:
isMoved = true;
if (!samoKlik) {
if (jedan) {
break;
case TouchPhase.Ended:
isMoved = false;
jedan = false;
break;
}