I need help on unity’s touch interface, I want to ‘do something’ when the user touches the gameobject (a cube), for example : load level 1 when user touches the cube.
Can anyone please help me ? Thank you For your time.
This should be fairly simple. Iterate through all the touches, ray cast for each one, and check if you hit anything:
function Update () {
var tapCount = Input.touchCount;
for (var i = 0; i < tapCount; i++) {
var touch = Input.GetTouch(i);
var hit : RaycastHit;
if (Physics.Raycast ( Camera.main.ScreenPointToRay(touch.position) , out hit ) ) {
//Do stuff with the `hit` information
}
}
}