title: Convert 3D Raycast to Raycast2D
body: <p>I have this code below which could control a touched player among 3 players. I was able to implement it by like sort of "cheating" by way of adding a 3D cube behind a 2D sprite since my game should be in 2D and I am having hard time implementing it in 2D. I'm really confused on how to do it in 2D because I'm really confuse on the parameters.</p>
  
  <p>Although I already implemented it by the way mentioned above, I still want to implement it in pure 2D. And  because I have this problem when the selected player moves, the sprite moves faster.</p>
  
  <pre><code>public GameObject target = null;
  
  // Use this for initialization
  void Start () {
  }
  
  // Update is called once per frame
  void Update () 
  {
     if(Input.touchCount &gt; 0 || Input.GetTouch(0).phase == TouchPhase.Began)
     {
         Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
         Debug.DrawRay(ray.origin,ray.direction * 20,Color.red);
         RaycastHit hit;
         if(Physics.Raycast(ray, out hit,Mathf.Infinity))
         {
              Debug.Log(hit.transform.gameObject.name);
              if(this.target != null){
                  SelectMove sm = this.target.GetComponent&lt;SelectMove&gt;();
                  if(sm != null){ sm.enabled = false; }
              }
              target = hit.transform.gameObject; 
              //Destroy(hit.transform.gameObject);
              selectedPlayer();
          }
      }
  }
  
  void selectedPlayer(){
      SelectMove sm = this.target.GetComponent&lt;SelectMove&gt;();
      if(sm == null){
          target.AddComponent&lt;SelectMove&gt;();
      }
      sm.enabled = true;  
  }
  </code></pre>