Swipe function

Hi, I am doing a swipe function for a football game. How do I get the following items?

  1. StartSwipeTime
  2. EndSwipeTime
  3. StartSwipePoint/Coordinate
  4. EndSwipePoint/Coordinate

I have the direction of the swipe → gesture.swipeVector.normalized.
What is the function to move the object based on speed of swipe, length of swipe and direction of swipe?

Thanks!

All touch input is handled through Input.touches. For swipe gestures, you want to consider the touchphase.Began and touchphase.Ended phases of each touch.

1.) 2.) To determine the start/end time of a swipe, record the time at which these phases occur (measured since game start) using Time.time.

3.) 4.) For coordinates, look at the position of the touch, which gives coordinates as a Vector2

I found my answers, here’s the code for reference. Note: I’m using Easytouch.

void On_DragStart(Gesture gesture){
		// Verification that the action on the object
		if (gesture.pickObject == gameObject){
			position = gesture.GetTouchToWordlPoint(13);
		}
		dragStartPos = position;
		dragTimeBegin = Time.time;
	} //same with On_DragEnd.

Then Vector3.Distance (a,b) to get the distance and endTime - startTime to get the time :slight_smile:

Thanks!