Here is a methodology you can maybe try :
00. Define the path the user has to trace, and store it
One way to go would be to place gameObjects along the path of your word, and then check if the player traces over them in the sequence you wish.
If you store their Vector3 or Vector2 positions in a list, you can then easily access the preceding/next point in the path you want to player to trace.
I would store them as a list of Vector2 values.
Your object would be something like this :
- LETTER with script with Vector2 list + a collider (for Raycasting)
---- point1
---- point2
---- point3
1. Get the finger position
You can use Screenpoint to Ray to get the position of the finger :
Touch touch = Input.GetTouch(0);
Vector2 fingerPos = new Vector2(touch.position.x, touch.position.y);
ray = Camera.main.ScreenPointToRay(fingerPos);
2. Get where this finger is on the surface of the letter
Then you can check if this Raycast is hitting the collider your put on the letter object :
Vector3 hitpoint;
if (Physics.Raycast(ray, out hit))
{
hitpoint = hit.point;
}
You can then use this position to check the distance between the finger and the next point you want to trace, or if the finger is over the current point in the list the user has to get right.
3. Keep track of the path the finger is tracing on the letter
You can use the List to check the order the player is tracing over.
When a point is traced over, set the next point in the list as the next target, and check if the finger is getting over it.
You can then add a way to keep track of the delay between the last point being traced over and the next, so you can use this value, for example, to reset the traced path if the user takes too long.