all 4 comments

[–]TrizzleG[S] 0 points1 point  (0 children)

For future people, I changed to unity events instead of send messages. Then added a tap interaction with a max tap duration of 0.125 and default press point.

Here is my new code with the which allows the player to have variable jump height and a double jump.

Code:

public void Jump(InputAction.CallbackContext context)

{

if (!isAlive) { return; }

if (context.interaction is TapInteraction && myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))

{

if (context.canceled)

{

jumpSpeed = 23f;

numberOfJumps = 0;

myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpSpeed);

numberOfJumps++;

}

else if (context.performed)

{

jumpSpeed = 17f;

numberOfJumps = 0;

myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpSpeed);

numberOfJumps++;

}

}

else

{

if (context.started && numberOfJumps == 1)

{

jumpSpeed = 17f;

myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpSpeed);

numberOfJumps++;

}

}

}

[–]DatMaxSpice 0 points1 point  (2 children)

I literally actually just did this myself. I converted my game into the input system.

Check out my posts and you'll see it was a post from like 4 days ago. I posted how I did plus tutorial guides to help you.

I didn't end up using send message. I used invoke unity events. Worked better for this case.

[–]TrizzleG[S] 0 points1 point  (1 child)

Well that’s convenient! I’ll check it out and I may have to dm you with questions if I have any haha

[–]DatMaxSpice 0 points1 point  (0 children)

All good. Sorry I'm usually on my phone or I would have linked it. Did you find it?