So i have this code. This code lets me to move objects.And one thing that i can’t understand is how to change it that i only could move it horizontally? Any help would be nice :).
using UnityEngine;
using System.Collections;
public class TouchControl : MonoBehaviour {
float distance = 10;
void OnMouseDrag()
{
Vector3 mousePosition = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, distance);
Vector3 objPosition = Camera.main.ScreenToWorldPoint (mousePosition);
transform.position = objPosition;
}
}