Guestures trigger to often

I use the swipe guestures to scroll but it triggers when the user is just moving there hand to get ready to swipe.

So if I swipe right my hand is on the right so to swipe right again i need to move my hand to the left to swipe right again. But when I move my hand left it detects a swipe left even though i try to move my hand slowly.

I hope somebody knows a way to filter the unnecessary swipes.

I use unity 2018.1.4f
intel d435

Hi TheNoNinja,

Nuitrack doesn’t provide the tools to filter the unnecessary swipes. You can try the following: find the speed of a hand joint in Unity (Skeleton Tracker) and filter the “slow swipes” using this data.

Thanks for the reply. I eventually did something like that and it work much better now. For the people that might have this problem in de future here is the psuedo code:

//The Variabes you should only read
bool swipeLeft = false; 
bool swipeRight = false;
float timeout = 0;

//Variables you can tweak to your liking
float treshHold = 35;
float treshHoldToDeactivate = 10;
float minTimeBetweenSwipes = 0.5f;

//Variable used for calculation
float handDistanceFromLastPosition = Hand.position - Vector2.lerp(Hand.position, new Vector2(skeleton.hand.postion), 0.15f) ;

//The filter to check if user swiped
if (handDistanceFromLastPosition  > treshHold){
    if (timeout < 0)
    {
        swipeLeft = true;
        fixSwipe = true;
        timeout = minTimeBetweenSwipes;
    }
} else  if (handDistanceFromLastPosition  < -treshHold){
    if (timeout < 0)
    {
        swipeRight = true;
        fixSwipe = true;
        timeout = minTimeBetweenSwipes;
    }
} else if (handDistanceFromLastPosition  < treshHoldToDeactivate && handDistanceFromLastPosition  > -treshHoldToDeactivate ) {
    timeout -= Time.deltaTime;
}



//Usecase
private void Update(){
    if(swipeLeft){
        swipeLeft = false;
        DoTheThingWhatYouWantWhenUserSwipedLeft();
    }

    if(swipeRight){
        swipeRight = false;
        DoTheThingWhatYouWantWhenUserSwipedRight();
    }
}

This works perfectly for me.

1 Like