Why won't this jump code work?

I’ve been following this tutorial on making a character controller and I’m trying to get the player to jump but only when it’s grounded. Here is the code.

public class WalkingController : Controller
{
    //Movement information
    Vector3 walkVelocity;
    Vector3 previousWalkVeloctiy;
    float adjVertVelocity;
    float jumpPressTime;


    //Setting
    public float walkSpeed;
    public float jumpSpeed;


    public override void ReadInput(InputData data)
    {
        previousWalkVeloctiy = walkVelocity;
        ResetValues();

        //set horizontal movement.
        if(data.axes[0] != 0f)
        {
            walkVelocity += Vector3.right * data.axes[0] * walkSpeed;
        }

        //set jump movement.
        if (data.buttons[0] == true)
        {
            if (jumpPressTime == 0f)
            {
                if (Grounded())
                {
                    adjVertVelocity = jumpSpeed;
                }
            }
            jumpPressTime += Time.deltaTime;
        }
        else
        {
            jumpPressTime = 0f;
        }


        newInput = true;
    }

    //method that looks below the player to see if something is there.
    bool Grounded()
    {
        return Physics.Raycast(transform.position, Vector3.down, coll.bounds.extents.y + 0.1f);
    }

    void ResetValues()
    {
        walkVelocity = Vector3.zero;
        adjVertVelocity = 0f;
    }

    void LateUpdate()
    {
        if (!newInput)
        {
            previousWalkVeloctiy = walkVelocity;
            ResetValues();
            jumpPressTime = 0f;
        }

        /*
         * FYI:
         * Here we set the Vectors to the velocity of the rigidbody. Setting the Y value of
         * the new Vector2 Means that the player will fall down normally. If set to 0 it would
         * either keep the player from falling or make them fall very slowly.
         */
        rb.velocity = new Vector3(walkVelocity.x, rb.velocity.y + adjVertVelocity);
        newInput = false;
    }

}

The tutorial is more designed for a 3d game, and I put this character controller on a cube just to see what would happen and it worked fine. I’m not sure why it wouldn’t work on a 2D sprite as well.
I even tried changing the raycast to be a 2D raycast, but that didn’t work to well because Raycast2D isn’t a bool like Physics.Raycast is. Any explaination would be greatly appreciated! :smiley:

You put the jumpPressTime += Time.deltaTime;

if(Grounded()){
jumpPressTime += Time.deltaTime;
adjVertVelocity = jumpSpeed;
}

i think