# Detecting points touched in sequence.

Using Rect(), I created 4 points as follows. (The co-ordinates are fake for now, cause my exacts co-ordinates are too long). The points are place in a diamond shape.

``````var p1 = Rect(x1,y1,10,10);
var p2 = Rect(x2,y2,10,10);
var p3 = Rect(x3,y3,10,10);
var p4 = Rect(x4,y4,10,10);

``````

This is how it will appear.

``````        [p1]
[p2]        [p3]
[p4]

``````

The player can use their fingers to move through the points to draw symbols. For start, I allow the users to draw Lightning, ^ and inverted ^. So lets say if player touches in the following sequence : (p1,p2,p3,p4). It draws a lightning shape. The player can also draw (p1,p3,p2,p4) to draw a reflected lightning shape. For the ^, the sequence is (p2,p1,p3) or (p3,p1,p2). For the last one, (p2,p4,p3) or (p3,p4,p2).

I tried using booleans but it ended up causing some booleans to be triggered unintentionally. I heard from my friend something about getting them into arrays but I got stuck at how to detect the sequence in the array.

Anyone can help?

Okay, Here it is explained a little more.

So, you want the player to draw a line...

X X X X X X X X X X

Above are 10 points... In order to pass, you need atleast 70 percent correct, so in other words, 7 of them must be right.

To do this, get the distance between what the user draws, and the actual game object (Represented by an X above)... Now, in the if statement to check if the distance is close enough, you can incrememnt a variable (Let's say, gotRight)...

So, when user is done drawing, whether it be pushing a button, or some other means, it checks between how many were possible (You can use http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html)

Now, that'll say how long, just use .length, and then divide the gotRight by the variable above, and that'll give you a percent. Now check whether or not that percent is >= .7, if so, then they got it right, if not, then they got it wrong...

Is that better?