+ 1
How to get touch input in unity
Hi guys i am using unity to developing games but i cant figure out how to get touch input in my games please help somebody please
3 Respostas
+ 1
you can use the Input class
eg:
using UnityEngine;
using System.Collections;
public class ClassName :MonoBehaviour
{
int touches=Input.touchCount;
void Update ()
{
if (touches >0)
{
for (int I =0; i <touches; i++)
{
Touch t = Input.GetTouch (i);
if (t.phase == TouchPhase.Began)
{
Ray Ray = Camera.main.ScreenPointToRay (t.position );
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
// insert your code here
// you can also check the object clicked by
// doing the following.
if (hit.transform.tag == "tag")
{
//do something
}
}
}
}
}
}
}
+ 1
Thanks for answer
0
Hi