I’m following this tutorial on making a platformer, but instead of using the Input.GetKeyDown(“space”) to jump I chose Input.GetAxisRaw(“vertical”) == 1. In the tutorial he uses Input.GetKeyUp(“space”) to signify when to reduce the vertical velocity.
Is there a way to do this for Input.GetAxisRaw(“vertical”) == 1 without creating an additional variable?
(tutorial’s code snippet)
if (Input.GetKeyUp("space")) {
// Do thing
}
(example of what I don’t want to do)
bool wasJumpingInLastFrame;
if (wasJumpingInLastFrame && Input.GetAxisRaw == 0) {
// Do thing after involving additional variable
}
if (Input.GetAxisRaw("vertical") == 1) {
wasJumpingInLastFrame = true;
} else {
wasJumpingInLastFrame = false;
}