- Home /
Semi circular Touch Input
I want to take touch input in a semi circular way. Something like this:
I thought of taking 3 points starting, end and third point will be normalize of starting and End point. If all the 3 points are touched then it is a semi circle swipe. If there is any other way of doing it, then please tell me.
This is how I solved it. If some one has a better answser then please comment below
private Touch prevTouch = new Touch(); public bool Yincrease = false; public bool Ydecrease = false; bool flag; int yValue;
void FixedUpdate() {
foreach(Touch t in Input.touches) {
if (t.phase == TouchPhase.Began) {
prevTouch = t;
flag = true;
}
else if(t.phase == TouchPhase.$$anonymous$$oved) {
if (prevTouch.position.x < t.position.x) {
if (flag) {
if (prevTouch.position.y > t.position.y) {
yValue = 1;
}
else if (prevTouch.position.y < t.position.y) {
yValue = 2;
}
flag = false;
}
if (prevTouch.position.y > t.position.y) {
Yincrease = true;
}
else if (prevTouch.position.y < t.position.y) {
Ydecrease = true;
}
}
//print(t.position);
prevTouch = t;
}
else if(t.phase == TouchPhase.Ended) {
prevTouch = new Touch();
if (yValue == 1) {
if (Yincrease && Ydecrease) {
BottomSwipe();
}
}
else if (yValue == 2) {
if (Yincrease && Ydecrease) {
TopSwipe();
}
}
Yincrease = false;
Ydecrease = false;
}
}
}
void TopSwipe() {
print("Swiped top");
}
void BottomSwipe() {
print("Swiped Bottom");
}
void Swipe() {
print("Use Swipe");
}
Your answer
Follow this Question
Related Questions
Drag and DoubleTap from mouse to touch??? 0 Answers
Android Multi touches not working 1 Answer
How to Raycast on Touch? 3 Answers
it does not wait for user to touch,unity does not wait for me to touch a game object 0 Answers
The type or namespace name `Events' does not exist in the namespace `TouchScript' 1 Answer