title: Get player to jump with touch screen control
body: <p>Hello and thanks for reading this post.</p>
  
  <p>I have 2 objects: A player Object and a JumpButton Object.</p>
  
  <p>The Player object is the player. ofc. The JumpButton Object is an object that I want to make the player jump when you use a touch screen device aka android phone.</p>
  
  <p>This is my Script that is assinged to my JumpButton: using UnityEngine; using System.Collections;</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class JumpButtonScript : MonoBehaviour {
  public GameObject player;
  public GameObject JumpButton;
  
  // Use this for initialization
  void Start () {
      player = GameObject.Find ("player");
  }
  
  // Update is called once per frame
  void Update () {
      if ((Input.touchCount == 1) &amp;&amp; (Input.GetTouch(0).phase == TouchPhase.Began)) 
      {
  
      }
    }
  }
  </code></pre>
  
  <p>This is the script that allows me to control the player with arrow keys.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class RobotController : MonoBehaviour {
  //This will be our maximum speed as we will always be multiplying by 1
  public float maxSpeed = 2f;
  public GameObject player;
  public GameObject sprite;
  //a boolean value to represent whether we are facing left or not
  bool facingLeft = true;
  //a value to represent our Animator
  Animator anim;
  //to check ground and to have a jumpforce we can change in the editor
  bool grounded = true;
  public Transform groundCheck;
  public float groundRadius = 1f;
  public LayerMask whatIsGround;
  public float jumpForce = 300f;
  private bool isOnGround = false;
  void OnCollisionEnter2D(Collision2D collision) {
          isOnGround = true;  
      }
  
  void OnCollisionExit2D(Collision2D collision) {
      anim.SetBool ("Ground", grounded);
  
      anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);
      isOnGround = false;
  }
  
  // Use this for initialization
  void Start () {
  
      player = GameObject.Find("player");
  
      //set anim to our animator
      anim = GetComponent &lt;Animator&gt;();
  }
  
  
  void FixedUpdate () {
      //set our vSpeed
      //set our grounded bool
  
      grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
      //set ground in our Animator to match grounded
      anim.SetBool ("Ground", grounded);
  
      float move = Input.GetAxis ("Horizontal");//Gives us of one if we are moving via the arrow keys
      //move our Players rigidbody
      rigidbody2D.velocity = new Vector3 (move * maxSpeed, rigidbody2D.velocity.y);   
      //set our speed
      anim.SetFloat ("Speed",Mathf.Abs (move));
      //if we are moving left but not facing left flip, and vice versa
      if (move &gt; 0 &amp;&amp; !facingLeft) {
  
          Flip ();
      } else if (move &lt; 0 &amp;&amp; facingLeft) {
          Flip ();
      }
  
  }
  
  void Update(){
      if ((isOnGround == true &amp;&amp; Input.GetKeyDown (KeyCode.UpArrow)) || (isOnGround == true &amp;&amp; Input.GetKeyDown (KeyCode.Space))) {
          anim.SetBool("Ground",false);
          rigidbody2D.AddForce (new Vector2 (0, jumpForce));
      }
  
      if (isOnGround == true &amp;&amp; Input.GetKeyDown (KeyCode.DownArrow)) 
      {
          gameObject.transform.localScale = new Vector3(transform.localScale.x, 0.2f, 0.2f);
      }
      if (isOnGround == true &amp;&amp; Input.GetKeyUp (KeyCode.DownArrow)) 
      {
          gameObject.transform.localScale = new Vector3(transform.localScale.x, 0.3f, 0.3f);
      }
  }
  
  
  
  //flip if needed
  void Flip(){
      facingLeft = !facingLeft;
      Vector3 theScale = transform.localScale;
      theScale.x *= -1;
      transform.localScale = theScale;
  }
  }
  </code></pre>
  
  <p>As you can see, then I managed to make the player move on arrow keys, but how can I make it jump when I hit the jump button (touch Screen press), as on an Android Phone?</p>
  
  <p>I really hope you can help me. </p>