- Home /
Question by
Bunnehop0923 · Feb 22, 2021 at 08:38 PM ·
wall
stop player from holding input
my player can walljump but if the player holds down the walljump button the player will just walljump on its own basically I want the player not to be able to walljump for a few seconds
if (Input.GetKey(KeyCode.JoystickButton1)&& iswallsliding == true )
{
walljumping = true;
Invoke("walljumpfalse",walljumptime);
}
if(walljumping)
{
rb2d.velocity = new Vector2(xwalljump * -moveHorizontal,ywalljump);
}
Comment
Answer by L4t · Feb 22, 2021 at 09:11 PM
If you use Input.GetKeyDown
the action will only happen on the frame you pressed the button down.
You can also add a timer inside the Update.
private void Update()
{
timer += Time.deltaTime;
}
...
if (Input.GetKeyDown(myKey) && timer > 1f && iswallsliding)
{
// Do the jump
timer = 0f;
}
Your answer

Follow this Question
Related Questions
Object collision 2 Answers
Wall running using raycasting. 2 Answers
AI GameObjects Go Through Walls? 1 Answer
Raycast detects walls, how to disable movement or input in direction of the wall? 0 Answers
Wall Climbing and Default Gravity 1 Answer