Advertisement
Guest User

eaeae

a guest
Apr 18th, 2013
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Update () {
  2.     //**********************************************************************************
  3.     //||||||||||||||||||||||||||||| MOVEMENT |||||||||||||||||||||||||||||||||||||||||||
  4.     //**********************************************************************************
  5.     if (Input.touchCount > 0) // TOUCHSCREEN CONTROLS
  6.     {
  7.         // Get movement of the finger since last frame             
  8.         touchDeltaPosition = Input.GetTouch(0).deltaPosition;          
  9.  
  10.         // Getting the percentage of the screen that it moved (result is in decimal format like 0.3 for 30%)
  11.         touchDeltaPositionWindowPercentage.x = (touchDeltaPosition.x * 100 / globalValues.windowWidth) / 100;
  12.         touchDeltaPositionWindowPercentage.y = (touchDeltaPosition.y * 100 / globalValues.windowHeight) / 100;
  13.            
  14.         // Changing the screen percentage to real value
  15.         touchDeltaPosition.x = globalValues.windowWidth * touchDeltaPositionWindowPercentage.x * touchSpeed;
  16.         touchDeltaPosition.y = globalValues.windowHeight * touchDeltaPositionWindowPercentage.y * touchSpeed;
  17.  
  18.         // Move object according to new positions
  19.         transform.Translate(touchDeltaPosition * Time.deltaTime);
  20.         pos = transform.position;          
  21.         transform.position = pos;
  22.     }    
  23.     //**********************************************************************************
  24.     //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  25.     //**********************************************************************************
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement