title: Basic UNITY C# code for point on touch screen to point not working
body: <p>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</p>
  
  <pre><code>void Update () 
  {
      if (Input.touchCount &gt; 0 &amp;&amp; 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);
      }
  }
  </code></pre>