I’ve been trying to get my performJump method to detect when the jump button is released, but the code I put in isn’t working for some reason and it also won’t let me jump now. I previously asked about how to get the program to detect it, but it didn’t end up working, and looking at an old project it was working perfectly fine. I don’t know what I did wrong here, someone please help.
private void performJump(InputAction.CallbackContext ctx)
{
if (ctx.performed && isGrounded)
{
player.velocity = new Vector2 (player.velocity.x, jumpSpeed * Time.deltaTime);
Debug.Log ("boing");
}
if (ctx.canceled && !isGrounded)
{
player.velocity = new Vector2 (player.velocity.x, 0);
}
}
private void OnEnable()
{
playerControls.Enable();
jump.action.started += performJump;
jump.action.canceled -= performJump;
}
private void OnDisable()
{
playerControls.Disable();
}