GetButton and GetButtonUp

I am creating a glide ability for my character

if(Input.GetButton("Jump")){
		movement.gravity = 7;
}

if(Input.GetButtonUp("Jump")){
		movement.gravity = 25;
}

But it since like when I UP my button, it still keep on tracking GetButton, am I doing the wrong way? I know in order to hold the button I have to use GetButton but it since like GetButtonUp only work with GetButtonDown.

Any idea how to solve this?

Actually, I don’t see why you can’t use GetButtonDown in the first case, if movement.gravity is not changed by other function or behavior.

if(Input.GetButtonDown("Jump")){
       movement.gravity = 7;
}

if(Input.GetButtonUp("Jump")){
       movement.gravity = 25;
}

Anyway, the code you posted should already work since you check the “up-event” after the “hold-event”. During the “up-event” frame, both parts of code would be executed, but the latter will override the value as expected (that’s how I understand the input system). But if you want to make sure that no “hold-event” is detected during the “up-event”, then you can use a boolean guard:

boolean isUp = Input.GetButtonUp("Jump");
if(isUP)
{
    movement.gravity = 25;    
}
else if(Input.GetButton("Jump")){
       movement.gravity = 7;
}

Note that the boolean variable is not necessary, but I prefer it for better readability and you can reuse its value later.