title: How to convert keyboard controls to touch screen in Unity
body: <p>Complete newbie here. Using Unity C#. I'm looking at moving my PONG game from keyboard control to touch screen. Here is my working keyboard code:</p>
  
  <p>// Player 1 => Controls left bat with W/S keys</p>
  
  <p>public GameObject leftBat;</p>
  
  <p>// Use this for initialization
  void Start () {</p>
  
  <p>}</p>
  
  <p>// Update is called once per frame
  void Update () {</p>
  
  <pre><code>//Defualt speed of the bat to zero on every frame
  leftBat.GetComponent&lt;Rigidbody&gt;().velocity = new Vector3(0f, 0f, 0f);
  
  //If the player is pressing the W key...
  if (Input.GetKey (KeyCode.W)) {
  
      //Set the velocity to go up 1
      leftBat.GetComponent&lt;Rigidbody&gt;().velocity = new Vector3(0f, 8f, 0f);
  }
  
  //If the player is pressing the S key...
  else if (Input.GetKey (KeyCode.S)) {
  
      //Set the velocity to go down 1 (up -1)
      leftBat.GetComponent&lt;Rigidbody&gt;().velocity = new Vector3(0f, -8f, 0f);
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I found this code and been playing around with it but to now avail.</p>
  
  <p>using UnityEngine;
  using System.Collections;</p>
  
  <p>public class Player_Input_Controller : MonoBehaviour {</p>
  
  <pre><code>public GameObject leftBat;
  public float paddleSpeed = 1f;
  public float yU;
  public float yD;
  
  private Ray ray;
  private RaycastHit rayCastHit;
  
  private Vector3 playerPos = new Vector3(0, -9.5f, 0);
  
  // Update is called once per frame
  void Update () {
  
      if (Input.GetMouseButton (0))
      {
          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  
          if(Physics.Raycast(ray, out rayCastHit)){
              Vector3 position = rayCastHit.point;
  
              float yPos = position.y;
              playerPos = new Vector3(Mathf.Clamp(yPos, yU, yD), -9.5f, 0f);
              transform.position = playerPos; 
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any one have a touchscreen Pong script I could use, or know how to edit this one?</p>
  
  <p>Again, I'm really new and I'm sorry if I look like the Dummy in the class. </p>
  
  <p>Thanks for any help provided. I REALLY appreciate it. This is the last hurdle in completing my game.</p>