The code is basic and I want to convert my tap on screen to ray to the point Error=NullReferenceException: Object reference not set to an instance of an object. Thanks in advance
void Update ()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
rX = Camera.main.ScreenPointToRay(Input.GetTouch (0).position);
Physics.Raycast(rX,out hitX,Mathf.Infinity);
Debug.DrawRay(rX.origin, rX.direction * 200, Color.cyan);
}
}