- Home /
New Input System "Button On Press" doesn't work
I am using Unity's new Input System package, which is pretty great. I am trying to make a jump mechanic for first person movement, but the jump is triggered both when the jump button is pressed AND when it is released. I have set the Interaction to Press > Press Only, but it still triggers the jump on both press and release. How can I fix this? Here is the jump code:
public void OnJump(InputAction.CallbackContext context)
{
velY = jumpVel;
}
Answer by sacredgeometry · Jan 10, 2021 at 05:55 PM
have you configured the callback?
i.e.
Hi @sacredgeometry! Thanks for your reply!
Yes, the callback is set up, so the character is jumping when I press Jump. However, it also jumps when I release the space bar, resulting in a double-jump. I've tried adding a conditional like "If (controller.isGrounded)" in the jump function, but the input is still glitchy. When I have that conditional, sometimes the player is obviously touching the ground but doesn't jump when I press Jump. In addition, it sometimes does not jump when I press the Jump button but only when I release it. I tell you this just in case it is relevant at all to the issue I'm having. These might be two different issues, so I've gotten rid of the conditional, meaning the player can continue jumping in the air.
Your answer

Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
HoloLens: detect Airtap regardless of Raycast hit 0 Answers
VR not receiving controller position and rotation, but other buttons work fine 1 Answer
Does Unity provide a means to determine the time since the last user interaction? 2 Answers
How to make binary array toggle,How to make binary array switch/toggle? 0 Answers