Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update () {
- //**********************************************************************************
- //||||||||||||||||||||||||||||| MOVEMENT |||||||||||||||||||||||||||||||||||||||||||
- //**********************************************************************************
- if (Input.touchCount > 0) // TOUCHSCREEN CONTROLS
- {
- // Get movement of the finger since last frame
- touchDeltaPosition = Input.GetTouch(0).deltaPosition;
- // Getting the percentage of the screen that it moved (result is in decimal format like 0.3 for 30%)
- touchDeltaPositionWindowPercentage.x = (touchDeltaPosition.x * 100 / globalValues.windowWidth) / 100;
- touchDeltaPositionWindowPercentage.y = (touchDeltaPosition.y * 100 / globalValues.windowHeight) / 100;
- // Changing the screen percentage to real value
- touchDeltaPosition.x = globalValues.windowWidth * touchDeltaPositionWindowPercentage.x * touchSpeed;
- touchDeltaPosition.y = globalValues.windowHeight * touchDeltaPositionWindowPercentage.y * touchSpeed;
- // Move object according to new positions
- transform.Translate(touchDeltaPosition * Time.deltaTime);
- pos = transform.position;
- transform.position = pos;
- }
- //**********************************************************************************
- //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- //**********************************************************************************
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement