The new input system exposes a Gamepad object with buttons each button is a
ButtonControl that exposes accessors for the button state:
Input.GetKeyDown(KeyCode.JoystickButton2) ~= Gamepad.current.buttonWest.wasPressedThisFrame
Input.GetKey(KeyCode.JoystickButton2) ~= Gamepad.current.buttonWest.isPressed
Input.GetKeyUp(KeyCode.JoystickButton2) ~= Gamepad.current.buttonWest.wasReleasedThisFrame
Or if you want keyboard use Keyboard.
That lets you circumvent the new input system's configuration and hardcode your control scheme.
However, for supporting multiple input devices, you'd create a control scheme and use accessors on it:
Input.GetButton("fire") ~= m_Controls.fire.ReadValue<bool>()
Input.GetButtonUp("fire") ~= m_Controls.fire.triggered
Input.GetButtonDown("fire") ~= m_Controls.fire.triggered
triggered doesn't work quite like Input.GetButtonUp/Down. You'd configure the "fire" input for when during a press it should fire. You can set an input in your control scheme to be a Tap or SlowTap (ugh) and if it's a Tap, then triggered happens if it was released within the threshold time whereas SlowTaps are triggered if it's held for the threshold time.
You can also check which phase of press the input is in:
m_Controls.fire.phase == InputActionPhase.Started
If you go for this control scheme setup, see also this post about bad defaults.
I'd rewrite your code something like this (untested) and configure "jump" as a SlowTap with immediate activation:
void Jump()
{
// maybe need to clear isJumping if isTouchingGround?
if (isJumping)
{
if (m_Controls.gameplay.jump.ReadValue<bool>() && jumpTimeCounter > 0)
{
myRigidbody2D.velocity = new Vector2(myRigidbody2D.velocity.x, 1 * jumpSpeed);
jumpTimeCounter -= Time.deltaTime;
}
else
{
isJumping = false;
}
}
// Use triggered to avoid jumping again when we hold button on landing
else if (isTouchingGround && m_Controls.gameplay.jump.triggered)
{
isJumping = true;
jumpTimeCounter = jumpTime;
myRigidbody2D.velocity = new Vector2(myRigidbody2D.velocity.x, 1 * jumpSpeed);
}
}
(But I'm not particularly advanced with the new input system.)
I'd recommend playing around with the simple demo sample that can be imported from the package window. See how the different ways of using the system work.