Search Unity

Is possible to tap on object and detect it?

Discussion in 'Vuforia' started by iegghilba, Nov 13, 2017.

  1. iegghilba

    iegghilba

    Joined:
    Oct 20, 2017
    Posts:
    7
    Hi everyone,
    I'm building a simple scene (2017.3b) where I detect (with Vuforia) an ImageTarget showing a basic object.
    Is it possible to detect if I tap the object on the screen?
    If I show two objects, is possible to understand which one I tapped?

    Thanks
     
  2. vad710

    vad710

    Vuforia

    Joined:
    Dec 22, 2013
    Posts:
    13
    You should be able to detect when you tap an object on the screen by using a raycast.
     
    Vuforia-Strasza likes this.
  3. iegghilba

    iegghilba

    Joined:
    Oct 20, 2017
    Posts:
    7
    Yes, I should ...
    but the raycast is conditioned on the Input.touchCount and it is always 0.

    // Update is called once per frame
    void Update () {


    int i = 0;
    while (i < Input.touchCount) {
    if (Input.GetTouch(i).phase == TouchPhase.Began) {
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    ....