I’m making a puzzle-type game where the player taps a sphere at the right time to make it roll through a course or something. I’ve looked around and learned using Raycast might work, but I’m not really confident in my scripting. This is the script I have:
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
function Start () {
rigidbody.Sleep();
}
function Update () {
if (Physics.Raycast(ray, hit, 100)) {
rigidbody.WakeUp();
}
}
But, when I test it on my android device, I try to tap on the ball and nothing happens. Is there an error in my code, or am I completely taking the wrong approach to this?