Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
- {
- float touchDeltaPositionX = Input.GetTouch(0).deltaPosition.x;
- float position = this.transform.position.x;
- float touchDeltaPositionY = this.transform.position.y;
- if (position > -4f && position < 4f)
- {
- transform.Translate(touchDeltaPositionX * Time.deltaTime * sensitivitySlider.value, touchDeltaPositionY * 0, 0);
- }
- else if (position <= -4f)
- {
- if (touchDeltaPositionX > 0)
- {
- transform.Translate(touchDeltaPositionX * Time.deltaTime * sensitivitySlider.value, touchDeltaPositionY * 0, 0);
- }
- }
- else if (position >= 4f)
- {
- if (touchDeltaPositionX < 0)
- {
- transform.Translate(touchDeltaPositionX * Time.deltaTime * sensitivitySlider.value, touchDeltaPositionY * 0, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement