How to make the jump faster

Hi,

I have a script with a calculated, variable jump, and I dont know how to make the jump up faster than the falling down of the jump.

void Start(){
        gravity = -(2*maxJumpHeight)/Mathf.Pow(timeToJumpApex,2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
    }

    void Update(){
        // JUMP
        if(Input.GetKeyDown(KeyCode.Space) && controller.collisions.below){
            velocity.y = maxJumpVelocity;
        }

        if(Input.GetKeyUp(KeyCode.Space)){
            if(velocity.y > minJumpVelocity){
                velocity.y = minJumpVelocity;
            }
        }

The problem is if I increase the velocity.y the jump just gets higher, cause there is nothing like a “highest jump position”.
Can you give me some advice?

Greetings J.

Changing the value of gravity will change how fast your character accelerates. You’ll find many games actually use a gravity value of around 30 instead of the realistic 10.

If you want to keep the jump height the same, you will need to update maxJumpVelocity and gravity.

1 Like

Thank You! You mean something like this? :

    void Start(){
        gravity = -(2*maxJumpHeight)/Mathf.Pow(timeToJumpApex,2);
        startGravity = gravity;
        minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
    }
    void Update(){
        gravity = -(2*maxJumpHeight)/Mathf.Pow(timeToJumpApex,2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        // JUMP
        if(Input.GetKeyDown(KeyCode.Space) && controller.collisions.below){
            if(velocity.y > 0){
                 gravity = 30;
            } else {
                 gravity = startGravity;
            }
            velocity.y = maxJumpVelocity;
        }
        if(Input.GetKeyUp(KeyCode.Space)){
            if(velocity.y > minJumpVelocity){
                velocity.y = minJumpVelocity;
            }
        }
    }