- Home /
Pattern comparing in unity
I'm new to programming with unity and i want to make game with touch pattern feature in android game with unity..
is there any feature to compare the touch input with the background like the pict? thx
Just so you know, you've tagged this "pattern-matching", but this actually isn't what "pattern-matching" is.
As @hoeloe says, this is not pattern matching, and I don't know what you are asking. Are you trying to create a touch pad...map a small section of the screen to the whole screen and move an object? Note there is unlikely to be a "feature," but most problems can be solved with code.
If I understand correctly, what you're looking for is something like this: http://youtu.be/Rz_-XgaWZl4?t=2m20s
There are multiple ways you can do this. The one used in this video looks to me to be one that just logs the position of the mouse every so often, and compares the distance of those positions from the source curve (the one you've drawn in grey). It will accept if all distances are below a threshold, and decline if any of them is too large.
The way I would probably do this is actually with image analysis. First, you again log discrete points of the mouse, only this time, you draw them to a texture (using linear interpolation to fill the gaps between the discrete points). Then, you take a texture containing just the source curve. You can then apply a "difference" filter to both of these curves. This filter takes 2 images, and returns a black and white image that gives the difference between the two, with black being no difference, and white being totally different. You would then combine the pixels of this difference image into one number, either by sum$$anonymous$$g, multiplying, averaging, the method is up to you. Then, you test this total difference value against a threshold, below which, you accept, and above which, you decline.
sorry for the wrong tag im new in this..
@hoeloe yeah like you said im looking for something like the vid but since im new to program$$anonymous$$g i dont really know what to do..
can u show some example code? thanks again..
Answer by sajjadgameactor · Mar 02, 2020 at 11:10 AM
You can use this asset https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076