- Home /
 
 
               Question by 
               Paladin · Aug 08, 2013 at 12:35 PM · 
                movement script  
              
 
              Object slide like ice without collision
hi,
I have a GameObject wich move when we moved one finger on the screen with this script:
 if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
             
         touchDeltaPosition = Input.GetTouch(0).deltaPosition;
             
         transform.Translate(touchDeltaPosition.x*speed,
         touchDeltaPosition.y*speed, 0);
                 
 }
 
               Now i would want if I remove my finger to the screen and i moved my finger fast, the GameObject continue this run with deceleration to a stop but not if i move it slowly.
Any ideas how to do this?
               Comment
              
 
               
              Answer by Mill0698 · Aug 08, 2013 at 01:40 PM
If I understand your question correctly, all you are looking for is Velocity?
position += velocity * dt;
yes it is. And I saw in an other topic we calculate the velocity like this:
 current = Input.GetTouch(0).position;
 previous = Input.GetTouch(0).deltaPosition;
 
 velocity = (current - previous)/time.deltaTime;
 
                  then I tried that :
 if(Input.GetTouch(0).phase == TouchPhase.$$anonymous$$oved){
  touchDeltaPosition = Input.GetTouch(0).deltaPosition;
       manager.transform.Translate(touchDeltaPosition.x+=( (Input.GetTouch(0).position.x - Input.GetTouch(0).deltaPosition.x)/Time.deltaTime)* speedPan,touchDeltaPosition.y+= ((Input.GetTouch(0).position.y - Input.GetTouch(0).deltaPosition.y)/Time.deltaTime)*speedPan, 0);
 }
 
                  but that didn't work at all><. What I doing wrong please?
Your answer