Check out example codes for "Movement 2d unity". It will help you in understanding the concepts better.

Code Example 1

public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed;
    public float jumpHeight;

    void Start()
    {
    
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
        }

        if (Input.GetKey(KeyCode.D))
        {
            GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, 0);
        }

        if (Input.GetKey(KeyCode.A))
        {
            GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, 0);
        }
    }
}

Code Example 2

public float MoveSpeed;
public float jumpPower;
public bool Cground = false;
  void Start()
  {
  }
  void Udpate ()
  {
      Jump();
      Vector3 Move = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
	  transform.postion += Move * Time.deltaTime * MoveSpeed;
  }
  void Jump ()
  {
      if (Input.GetKeyDown(KeyCode.Space) && Cground = true)
      {
      	gameObject.AddForce(new Vector2(0f, JumpPower), ForceMode2D.Impulse);
        Cground = false;
      }
  }

  void OnCollisionEnter2D(Collision2D other)
  {
      Cground = true 
  }

Learn ReactJs, React Native from akashmittal.com