Get user's touch and possibly compare it to a known input

Hello everybody.
What i would need is to get the user input on the touchscreen and possibly compare it with a known symbol.
I mean if the user draw an L on the screen i would like to get it and compare it with a predefined L that i have done before.
So my 2 doubt are:
-how to get it
-how to compare it, i’m actually asking if at least exists some api that tells me a certain % of matching between the two input.

thanks in advance for your always great help!!!

up

If by touchscreen you mean a mobile device, then Input.GetTouch() will give you the touch location as I am sure you know. On PCs, you might need:

https://software.intel.com/en-us/blogs/2012/11/07/adding-multi-touch-support-in-unity-windows-apps

There is no Unity feature that can compare touch points against letter shapes. That is really an exercise for you to write.

thanks for your answer.
My game should be just for smartphone/tablet.
do you know if input.getTouch returns only the location of a small touch or even a sort of array of position if i do a swipe?

It returns the position of the touch in the current frame. Typically you’d collect the touches over time, perhaps drawing a line showing where the system thinks the user is touching, until the user lifts their finger. You then have a list/array of touch positions. For a letter like Q or T, the user will often make another swipe, in which case your letter drawing might be composed of lots of swipes. Capital E might be drawn with 1 swipe (more like drawing backwards number 3), 2 swipes (like two c-letter one on top of the other), or perhaps 4 swipes. The order of these swipes is user-preference. Working out what someone has drawn, and if it meets some letter form isn’t easy.

Thanks again for the fast answer.
I just have to implement a system that let the user to draw “simple” things and with simple i mean gestures that can be done with a single swipe.(without removing the finger from the screen)
The idea is the one of the image below, in which appears an arrow to guide the user and he has to do it again in order to proceed in the game.
Someone suggested me touchscript to implement it, but i’ve not actually found the way to do it.
Any other suggestion?
Thanks in advance for help.

1845926--118388--uncharted_313891.jpg

In that case, just use the Input.GetTouch(). Each touch event has a value that tells you if it’s the start, end, movement, or stationary touch. Track touches from start, movement, and end, and write them into an array. When the touch ends, look at the positions you’ve recorded and work out how close they are to the swipe you want them to perform. Look at the code I wrote here:

It’s not exactly what you want, but might serve as an inspiration for how to track the finger movement and draw some debugging lines.