Hello,
Currently I’m working on swipe detection controls just to test them out. I currently have it detecting 8 way swipe, and very limited quarter circle swipe. What I mean by this is that it will pick up that a quarter circle is a happening in one direction but not another. For example Quarter circle back is detected when a finger is moved in a quarter circle up and to the left (negative movement on the x axis and positive movement on the y axis). Trying any other way will cause another quarter circle swipe to be detected. Attached is a snippet of code as to how the detection works. Any help would be greatly appreciated.
if (t.phase == TouchPhase.Moved) {
position.Add (new Vector2 (t.position.x, t.position.y));
}
if (t.phase == TouchPhase.Ended) {
if (t.fingerId == finIdL) {
secondPressPos = new Vector2 (t.position.x, t.position.y);
position.Add (new Vector2 (secondPressPos.x, secondPressPos.y));
currentSwipe = new Vector3 (secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
StarttoMid = new Vector3 (position [z/ 2].x - firstPressPos.x, position [z / 2].y - firstPressPos.y);
MidtoEnd = new Vector3 (secondPressPos.x - position [z / 2].x, secondPressPos.y - position [z / 2].y);
Total = StarttoMid.magnitude + MidtoEnd.magnitude;
finIdL = -1;
CoordinateX.LX = currentSwipe.magnitude;
CoordinateY.LY = Total;
compare = currentSwipe.magnitude;
position.Clear();
}
}
if (currentSwipe.magnitude < minSwipeLength)
{
SwipeText1.Ltouchtype = "LTap";
leftSwipe = LSwipe.LTap;
return;
}
else if (currentSwipe.y > 0 && currentSwipe.x < 0)
{
if (Total > compare+buffer)
{
SwipeText1.Ltouchtype = "LQCB";
leftSwipe = LSwipe.LQCB;
}
else
{
SwipeText1.Ltouchtype = "LSUL";
leftSwipe = LSwipe.LUpL;
}