Touch Scrolling momentum

Hello everyone

I have been using a .js touch script for use with a sidescroller and it works lovely.

(Script Below)

But now I want to add momentum after the user lifts their finger…
Any Ideas?

#pragma strict

// Moves object according to finger movement on the screen

	var speed : float = 0.05;
	var nonSpeed : float = 0;
	
	function Update () {
		if (Input.touchCount > 0 && 
		  Input.GetTouch(0).phase == TouchPhase.Moved) {
		
			// Get movement of the finger since last frame
			var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
			
			// Move object across XY plane
			transform.Translate (-touchDeltaPosition.x * speed,
			0,0);
			// -touchDeltaPosition.y * nonSpeed,0);			 
		
		}
	}

Thanks Y’all

~be

Although it’s been a little late for the answer to be given but for pple who had same problem (I know that the original question was in javascript but Im using c#, so excuse me),
I’ve had the same problem and I end up adding rigid body to my object and then a Constant Force component to it.
then In the rotation code, I called a CoRoutin in which I assign a value to Y part of relative torque of the constant force component and in some seconds I set it from 4 to 0.

 IEnumerator slowDown(bool forward /*check if the movement is in the positive direction or negative direction*/){
                    //the initial value of relative torque's Y
    		speed = 4;
    		while (speed > 0) {
    			speed -= 0.5f;
          
//cf has been assigned in Start function to be the Constant Force component of the game object
    			cf.relativeTorque = new Vector3(0f,forward?speed:-speed,0f);
    yield return new WaitForSecondsRealtime (1f);
    		}
                 // we make sure everything is 0 after the while loop has been finished
    		cf.relativeTorque = new Vector3(0f,0f,0f);
    		yield return new WaitForSecondsRealtime (0f);
    
    	}

It is working good in my case and you may need to add more logic or change default values to better
tune it with your environment.