Drag touch iPhone X point from A to B/ B to A

Hello people,

I need help for drag touch (moving left or right). I have one object which I need to dragging only on X coordinate. Something like on this picture below:

Thanks :slight_smile:

I solve my problem with this code.

using UnityEngine;
using System.Collections;

public class movingBox : MonoBehaviour {

public float speed = 0.1f;
void  Update (){
	if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
		// Get movement of the finger since last frame
		Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
		// Move object across XY plane
		transform.Translate(touchDeltaPosition.x * speed, 0, 0);
	}
}

}

I hope that it will help for someone.

Thanks :slight_smile:
Kind regards.