Tap for variable height jump, swipe to dash

Hi,

This may be a weird/interesting question. I’m currently working on a 2D, side scrolling, endless running game. Current touch input accounts for the following:

tap - jump
swipe right - speed boost
swipe down - drop to platform below

I’ve coded it so that my character can also do variable height jumping - meaning the longer the touch is held, the higher the character jumps - so I set the character to jump on touchphase.began.

Well the issues start when the player swipes right - the character will jump first, then dash (which makes sense since I’m also setting the character to jump on TouchPhase.Began. The best I’ve been able to do is cancel as much of the initial jump as possible by setting the rigidbody velocity to zero, then executing my dash code - but it looks awkward.

Any thoughts on how to approach this? I can’t do tap detection on TouchPhase.End because the character won’t jump until the player lifts their finger off the screen.

I’ve tried TouchPhase.stationary, but it’s pretty iffy.

Any other thoughts?

Thanks in advance.

You can check for the the delta position on the first touch.
If it is smaller than some number, than you jump, oterwise use swipe input.

This could be over sensible , so another option would be to jump once the finger is released, but it feels kind of awkward if the character doesn’t jump immediately.

I would check after about two or three frames (you have to play around with this number) what the total deltaPosition is, so that is somewhat of a mixture of the two answers named above.