-1

I am creating an app in Unity, where the user will be presented by alphabets images and user will be able to trace the character in the image using his finger. I know how to do the tracing part in Unity but what I don't know is how to verify whether the character drawn by the user is correct or not.

For eg. User is presented with an image of character A. Now instead of drawing A user make character B. Now how can I verify that the user has drawn the wrong character and ask him to try again.

How can I achieve the above functionality? I don't have any code for this as don't have any idea how to progress with this.

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84

1 Answers1

1

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.

alpha_rats
  • 128
  • 2
  • 10