0

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);
    }
}
ryeMoss
  • 4,303
  • 1
  • 15
  • 34
Aniket Malik
  • 165
  • 1
  • 10

0 Answers0