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!