- Home /
having a subtle issue with my juump script
so i have done everything right with the jump script ( groundcheck and everything) but i m running into a subtle issue, if space bar is pressed and never released, my character starts to bunny hop and never stops which seems a bit absurd. i want my character to jump only when jump is pressed once and i cant find any solutions regarding this
Answer by $$anonymous$$ · Mar 26, 2021 at 09:51 PM
So if I understand you correctly then you want your player to only jump ones after you press the space bar not just jump continuously after holding it down so that would imply that one press one jump right if so try this.
Void update ()
{
bool press = false;
If (input.getKeyDown ( keycode.space ) && press == false)
{
// your method of jumping
press = true;
}
If (input.getKeyUp ( keycode.space ) && press == true)
{
press = false;
}
}
Your answer
Follow this Question
Related Questions
swipe player to up jump. 1 Answer
my player continuously jump when i press space-bar 1 Answer
my jump key works about once every 10 presses 1 Answer
jump on collision enter 1 Answer
Why are the player jumps lagging? 1 Answer