Simple 2D Jump Script

I’m in the process of making a 2D game, not really a platformer but it’ll control like one. So, I have a script that lets my character move left and right, and sprint by pressing the shift key. (See it below)

using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour
{

    public float speed = 200f;//walk speed
    public float sprint = 300f;//sprint speed
   
    void Start()
    {

    }

    void Update()
    {

        //sprint script
        if ((Input.GetKey(KeyCode.LeftShift))&(Input.GetKey(KeyCode.D)))//right
        {
            transform.position += new Vector3(sprint * Time.deltaTime, 0.0f, 0.0f);
            transform.localScale = new Vector3(-2, 2, 2);
        }

        if ((Input.GetKey(KeyCode.LeftShift)) & (Input.GetKey(KeyCode.A)))//left
        {
            transform.position -= new Vector3(sprint * Time.deltaTime, 0.0f, 0.0f);
            transform.localScale = new Vector3(2, 2, 2);
        }


        //walk script
        if (Input.GetKey(KeyCode.D))//right
        {
            transform.position += new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);
            transform.localScale = new Vector3(-2, 2, 2);
        }

        if (Input.GetKey(KeyCode.A))//left
        {
            transform.position -= new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);
            transform.localScale = new Vector3(2, 2, 2);
        }

    }
}

So now all I need is a script that lets him jump up and down. He has a rigidbody and a box collider, if that matters. I’m not worried about animations yet, so just a simple jump script. But if possible, I’d want the script to work so that when he’s sprinting, he would jump farther than when he’s walking. I don’t know how much work that would take, so if I’d need to rewrite all my code to do it then don’t worry about it. But if possible, he jumps farther when he’s sprinting (holding down shift). If you could put it into the code above, I’d really appreciate it, but just the script by itself is fine.

Im not much of a coding expert. Defently questioning the Vector3 where your suppose to use Vector2 for 2D. I think theirs a gravity thing for 2d that you could apply Gravity ON/OFF. I would do this. Sorry if Its not much help :wink:

public float timer = .1f;  

//Update thing
timer -= .1f * Time.DeltaTime * 1;
gravity = false  
if (timer <= 0) {
// idk what it is but 
gravity= true; 
timer = .1f; 
}
if (timer == .1f) {
gravity = false; 
}

Or you can use this GetComponent().AddFore(transform.up* A Number to control jump height);