Hello,
I`m new here, how can i convert mouse Input to touch Input for mobile? Thanks all!
void Update () {
if (Input.GetKeyDown("d"))
{
PlayerPrefs.DeleteAll();
}
if (transform.position.y < 0 && a && b)
{
if (PlayerPrefs.GetInt("mute") == 0)
{
sound.PlayOneShot(hoop);
//GetComponent<vibrator>().enabled = true;
Invoke("off", 0.2f);
Handheld.Vibrate();
}
winParticle.SetActive(true);
b = false;
Invoke("next", 1f);
}
if (rb.velocity == new Vector3(0, 0, 0) && a)
{
if (PlayerPrefs.GetInt("heart") > 1)
PlayerPrefs.SetInt("heart", PlayerPrefs.GetInt("heart") - 1);
else
PlayerPrefs.SetInt("heart", 3);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
if (Input.GetMouseButtonDown(0) && !a)
{
touchpos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
touchpos = Camera.main.ScreenToWorldPoint(touchpos);
}
if (Input.GetMouseButton(0) && !a)
{
Vector3 touchpos1 = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
touchpos1 = Camera.main.ScreenToWorldPoint(touchpos1);
gameObject.GetComponentInChildren<SpriteRenderer>().enabled = true;
dist =Vector3.Distance(touchpos,touchpos1)* 0.2f;
if (dist < 0)
dist = 0;
if (dist > 0.6f)
dist = 0.6f;
rotationX = (Input.GetAxis("Mouse X"));
transform.GetChild(0).transform.localScale = new Vector3(0.2f, dist *2.5f, 1f);
transform.Rotate(new Vector3(0, -rotationX * 200 * Time.deltaTime, 0));
}
if (Input.GetMouseButtonUp(0) && !a)
{
a = true;
gameObject.GetComponentInChildren<SpriteRenderer>().enabled = false;
rb.AddRelativeForce(0, 0, 5000 * dist*200 * Time.deltaTime);
}
}