title: 2D basic movement UNITY
body: <p>Currently my character works perfectly on the keyboard, but when I convert your movements to touch, through 3 UI Buttons (i tried UI image too, but success) i'm not succeeding</p>
  
  <p>It basically goes to the right, left, and jumps.</p>
  
  <p>How should do to make it follow these instructions:</p>
  
  <p>When the user presses directional, the character does not stop walking until the user user releases the button, and when you press the jump player jump.</p>
  
  <p>This is the script I use to move through the keyboard!</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Player : MonoBehaviour
  {
  
      public float velocity;
  
      public Transform player;
      private Animator animator;
  
      public bool isGrounded;
      public float force;
  
      public float jumpTime = 0.4f;
      public float jumpDelay = 0.4f;
      public bool jumped = false;
      public Transform ground;
  
      private Gerenciador gerenciador;
  
      // Use this for initialization
      void Start ()
      {
          gerenciador = FindObjectOfType (typeof(Gerenciador)) as Gerenciador;
          animator = player.GetComponent&lt;Animator&gt; ();
          gerenciador.StartGame ();
      }
  
      // Update is called once per frame
      void Update ()
      {
  
          Move ();
  
      }
  
      void Move ()
      {
  
          isGrounded = Physics2D.Linecast (this.transform.position, ground.position, 1 &lt;&lt; LayerMask.NameToLayer ("Floor"));
          animator.SetFloat ("run", Mathf.Abs (Input.GetAxis ("Horizontal")));
          if (Input.GetAxisRaw ("Horizontal") &gt; 0) {
  
              transform.Translate (Vector2.right * velocity * Time.deltaTime);
              transform.eulerAngles = new Vector2 (0, 0);
          }
          if (Input.GetAxisRaw ("Horizontal") &lt; 0) {
  
              transform.Translate (Vector2.right * velocity * Time.deltaTime);
              transform.eulerAngles = new Vector2 (0, 180);
          }
  
          if (Input.GetButtonDown ("Vertical") &amp;&amp; isGrounded &amp;&amp; !jumped) {
  
              //  rigidbody2D.AddForce (transform.up * force);
              GetComponent&lt;Rigidbody2D&gt; ().AddForce (transform.up * force);
              jumpTime = jumpDelay;
              animator.SetTrigger ("jump");
              jumped = true;
          }
  
          jumpTime -= Time.deltaTime;
  
          if (jumpTime &lt;= 0 &amp;&amp; isGrounded &amp;&amp; jumped) {
  
              animator.SetTrigger ("ground");
              jumped = false;
  
          }
      }
  }
  </code></pre>
  
  <p>C# if possible, remember i am using Canvas UI for these buttons =]</p>