- Home /
Taking Input from Android phones
I have this layout with buttons. How do I code it so that when I press Jump button it jumps(or does something else) and when I press rotate button, it rotates(or does something else) in Android OS. Any help, guys?
Comment
/* Since On$$anonymous$$ouseDown can not works on mobile we use ray to select the object */
if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
{
foreach (Touch t in Input.touches)
{
if (t.phase == TouchPhase.Began)
{
Ray r = Camera.main.ScreenPointToRay(t.position);
RaycastHit hitInfo;
if (Physics.Raycast(r, out hitInfo))
{
hitInfo.collider.Send$$anonymous$$essage("On$$anonymous$$ouseDown", Send$$anonymous$$essageOptions.DontRequireReceiver);
Debug.Log("RaycastHit");
}
}
}
}
Answer by JiffyJuff · Jul 04, 2013 at 09:02 AM
OnMouseDown. I heard it now works with touch.
Edit : Whoops, sorry, I was wrong. According to documentation. But I heard somewhere that it worked. You can try.