void CheckTouchMob() { for (int i = 0; i < Input.touchCount; i++) { if (Input.GetTouch(i).phase == TouchPhase.Moved || Input.GetTouch(i).phase == TouchPhase.Stationary) { Vector3 wp = guiCam.ScreenToWorldPoint(Input.GetTouch(i).position); Vector2 touchPos = new Vector2(wp.x, wp.y); Collider2D hit = Physics2D.OverlapPoint(touchPos); if (hit) { switch (hit.gameObject.name) { case "JoystickL": curentIdJoy = Input.GetTouch(i).fingerId; break; case "ButtonBone": curentIdBut = Input.GetTouch(i).fingerId; PlayerStats.curWeapone = CurrentWeapone.Bow; break; case "ButtonSword": PlayerStats.curWeapone = CurrentWeapone.Sword; break; } } if (curentIdJoy == Input.GetTouch(i).fingerId) { if (leftJoystick.Dist() > 0.25f) { player.rigidbody2D.velocity = leftJoystick.Move(touchPos) * PlayerStats.moveSpeed; } else { player.rigidbody2D.velocity = Vector2.zero; } player.transform.rotation = leftJoystick.Rotation(touchPos); } if (curentIdBut == Input.GetTouch(i).fingerId) { switch (PlayerStats.curWeapone) { case CurrentWeapone.Sword: FireSword(); break; case CurrentWeapone.Bow: FireBone(); break; } } } if (Input.GetTouch(i).phase == TouchPhase.Ended) { if (curentIdJoy == Input.GetTouch(i).fingerId) { curentIdJoy = -1; leftJoystick.JoystickReset(); player.rigidbody2D.velocity = Vector2.zero; } if (curentIdBut == Input.GetTouch(i).fingerId) { curentIdBut = -1; } } } }