Hi! I just started migrating from the Old Input System to the new one and I’m going crazy with this… Basically, I wanna do a variable jump height system (the more you hold the jump button, the higher the jump goes). I tried looking at the documentation, tried watching tutorials but I can’t figure out this part for NOTHING.
This is the current code (sorry for the mess)
public void Jump(InputAction.CallbackContext context)
{
if(isGrounded() )
{
if (context.started)
{
Debug.Log("started!");
isJumping = true;
_canJump = false;
jumpTimeCounter = jumpTime;
_rb.linearVelocity = new Vector3(_rb.linearVelocity.x, jumpForce, _rb.linearVelocity.z);
}
}
if(context.performed )
{
Debug.Log("performed!");
if(jumpTimeCounter > 0)
{
_canJump = false;
_rb.linearVelocity = new Vector3(_rb.linearVelocity.x, jumpForce, _rb.linearVelocity.z);
}
else
{
isJumping = false;
}
}
if(context.canceled)
{
isJumping = false;
}
I also added some Debug Logs to the context started and performed and I noticed both of em only log for 1 frame, which seems to make sense for context.started but I thought context.performed should log until I stop holding the jump key? Anyway, I’m pretty confused and would love if someone could hold my hand and solve it to me so I can understand what to do.
Thanks in advance!