Charging Jump

hello

I would like to make a charging jump button. so basically when the player presses and holds the jump button the jump strength will charge up. the player will be able to hold it for an X amount of time.

timer = 2
jumpStre = 200

so if the player is holding the jump button and decides to release it at 1 second the jump strength will be 100.

also it would need to work with gui buttons

thanks

This isn’t your final code, but hopefully it will get you where you want to be.

private float jumpStrength = 0f;

void OnGUI()
    {
    if(GUI.Button(YOURBUTTONSTUFFHERE))
        {
        jumpStrength += Time.deltaTime;
        if(jumpStrength >= 200)
             Jump();
        }
     else
        {
        if(jumpStrength > 0)
            Jump();
        }
    }

void Jump()
    {
    jumpStrength = 0f;
    //JUMP CODE HERE
    }