Slash across screen implementation

I’m working on a 2D game that implements a slash system similar to Fruit Ninja. You’ll slice across the screen and it will make a slash sound along with a visual to indicate the slash occured. Right now I’ve got it set up so that the function is in the OnMouseDrag function with some checking to making sure the sound doesn’t occur too often and that there has to be a certain distance of movement from the mouse to initaite a swipe.

My problem is that current if you create a long enough slash, about half or more of the screen, it takes more than one frame to register that distance. So the slash sound will occur once while moving across the screen, and then a second time after it has already come to a complete stop. I was wondering if there was anyway to see if this motion was done in a single swipe over two frames and can differentiate it from two quick small swipes or a back and forth swipe which would both allow for multiple swipe sounds to occur.

Thanks!

This should be enough to give you an example of how to detect a single, long swipe, and see when it ends. You check the distance between the last mouse position and the current, if it’s big enough a swipe either starts or, if already busy, continues. At the end of every frame you save the mouse position;

var lastMousePosition : Vector3;
var minSwipeDistance : float; //this is per frame
var swiping : boolean = false;
function Start(){
    lastMousePosition = Input.mousePosition;
}
function Update(){
    if( !swiping )
        if(  )
            Swipe();
    lastMousePosition = Input.mousePosition;
}
function Swipe(){
    while( Vector3.Distance( Input.mousePosition, lastMousePosition ) > minSwipeDistance )
    {
        //a swipe is going on. Have a particle effect at the mouseposition, for instance.
        yield;
    }
    swiping = false; // swipe has ended
}