Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity 2d C# Touch Code help

Discussion in 'Scripting' started by Chuko32, Apr 21, 2020.

  1. Chuko32

    Chuko32

    Joined:
    Mar 25, 2018
    Posts:
    3
    Good morning, I am new to unity and C #, and even though I have read and seen tutorials everywhere, I cannot understand how touch works.

    I need your help if possible.
    What I need is to know how to differentiate between a simple touch on the screen, or when the user drags his finger.
    In the game I'm creating, you should find hidden elements in an image, with a tap, you should indicate where you think the object is, and by zooming, you should be able to drag your finger on the screen to move around the image, and touch where you think the object is.

    I just need to know how to tell the difference between simple touch and drag.

    Currently I move the camera like this when the user zooms:
    CameraZoom.transform.Translate (Input.GetTouch (0) .deltaPosition * Time.deltaTime * 1f);

    To detect the simple touch on the screen, I currently use the function:
    if (Input.GetMouseButtonDown (0))
    but i would like to use the touch function
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    Chuko32 likes this.
  3. Chuko32

    Chuko32

    Joined:
    Mar 25, 2018
    Posts:
    3
    Thank you very much for your answer, I have read the whole course, but unfortunately I am still at the same point as before, I still do not understand how to differentiate between a simple touch on the screen, and the sliding within it