Hi. I want to get an object’s name, by tapping it on an Android touchscreen, then pass it to another script.
I use this script:
function Update () {
if(Input.touchCount > 0)
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
if (Physics.Raycast(ray, hit, Mathf.Infinity)) {
anotherScript.whattomove = hit.rigidbody.gameObject.name;
}
}
}
I checked and Unity knows when i touch the screen, but this doesn’t work.
Any help would be appreciated. Thanks