Method that recognizes the touch of the screen of CELLULAR C #

3

I'm doing an augmented reality application with unity and vuforia. I created a class that makes the ball jump, now I need to insert this movement of the ball to a touch on the screen of the cell phone ... Does anyone know of any method that identifies this touch?

    
asked by anonymous 11.09.2015 / 17:18

1 answer

4

This is an example taken from a site tutorial of Unity3D.

using UnityEngine;
using System.Collections;

public class TouchTest : MonoBehaviour 
{
    void Update () 
    {
        Touch myTouch = Input.GetTouch(0);

        Touch[] myTouches = Input.touches;
        for(int i = 0; i < Input.touchCount; i++)
        {
            //Do something with the touches
        }
    }
}

You can pick up the touch coordinates for the instance of Touch which in the example is called myTouch and see if they collide with the ball you have on the screen. This for of the example is for you to iterate over the rings if more than one touch occurred at the same time.

    
11.09.2015 / 19:29