I am developing a mobile game in Unity for which I need the controls to be very responsive. I use the Lean Touch asset for touch detection. I am controlling my player with Lean FingerSwipe script, on four directions (UP, RIGHT, DOWN, LEFT), which triggers at the end of the swipe.
My problem is that I want the event to trigger at the beginning of the swipe, not at the end, but I can't find a way to do that. Do you know if there is an option or argument to do that?
Thank you
You can make the swipe feel responsive by triggering it exactly at the moment when the finger delta crosses the swipe threshold. As opposed to waiting for the finger to be lifted.
Copy and modify LeanFingerSwipe.cs from LeanTouch examples.
Firstly, instead of OnFingerSwipe
subscribe to OnFingerSet
.
LeanTouch.OnFingerSet += HandleFingerSwipe;
Secondly, inside the HandleFingerSwipe
function, add a guard.
if (finger.SwipeScreenDelta.magnitude * LeanTouch.ScalingFactor > LeanTouch.Instance.SwipeThreshold)
{
HandleFingerSwipe(finger, finger.StartScreenPosition, finger.ScreenPosition);
}