# How can I get the speed of finger drag using unity TouchPhase.Moved?

I'm making a mobile game where you control a 3d ball by touch. So far I can get it to roll based on finger down and drag (via TouchPhase.Moved) but I want to be able to detect a fast flick or finger swipe so that I can addforce based on finger speed and let go. Bit like how I would if I was only using TouchPhase.Began and TouchPhase.Ended with calculating start/end position and time duration, but now I think I need to do something in .Moved to keep track of finger speed and get the start and end position of the beginning and end of that fast finger movement. Here's my code so far:

if (Input.touchCount > 0)
{
touch = Input.GetTouch(0);

if (touch.phase == TouchPhase.Began)
{
touchdown = true;
}

if (touch.phase == TouchPhase.Moved)
{
if (touchdown == true)
{
startPos = new Vector2(0, 0);
}
else {
startPos = Input.GetTouch(0).position;
}

touchTimeStart = Time.time;

direction = startPos - endPos;
timeInterval = touchTimeFinish - touchTimeStart;

endPos = Input.GetTouch(0).position;
touchTimeFinish = Time.time;

rb.AddForce(direction.x * force, 0, direction.y * force/ moveSpeed);

touchdown1 = false;

} if (touch.phase == TouchPhase.Ended)
{
startPos = new Vector2(0, 0);
endPos = new Vector2(0, 0); } }

• It looks like the Unity Touch structure contains both deltaPosition and deltaTime variables from which you could create a velocity. How have you tried applying them to your case? Jul 9 '20 at 22:58
• Ok so i can get the deltaPosition which gives me a direction. I will need to get the average of deltaPosition vectors that occur in the moment the user is quickly swiping their finger. And also record the time at the start and end of that swipe for the amount of force. My question would then be how do I define the if() parameters in .Moved to notice that the finger is a swipe (quickly moving)? Jul 10 '20 at 1:55