Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
- {
- // Control sliding using touch input.
- Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
- transform.Translate(touchDeltaPosition.x * slidingSpeed, 0, 0);
- }
- transform.position = new Vector3 (Mathf.Clamp(transform.position.x, - xPosLimit, xPosLimit), transform.position.y, transform.position.z);
- }
Add Comment
Please, Sign In to add comment