I need help using raycast for unity iPhone. I have a game which contains a ball and a plane. The ball starts midair and gravity pushes it down. If it touches the plane, the game ends. I need help creating a script so when the player taps the ball, it bounces up. I already have the script to AddForce and make the ball bounce up, but I don’t know how to create the code that activates the addforce when I tap the ball.
Sample
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, 1000, 0))
{
//Use hitInfo to know which object was hit...
}
This should help you, I use this to check if I tapped 3D objects.
Cheers