Hey. I am trying to make a script that allows me to drag a object on x axis (which works)but for some reason it transforms on y axis… how to make that y axis would be locked i tried adding a rigidbody but the constrains are not working…
THIS IS MY SCRIPT FOR MOVING IT:
using UnityEngine;
using System.Collections;
public class TouchControl : MonoBehaviour {
float distance = 10;
void OnMouseDrag()
{
Vector3 mousePosition = new Vector3 (Input.mousePosition.x, 235, distance);
Vector3 objPosition = Camera.main.ScreenToWorldPoint (mousePosition);
transform.position = objPosition;
}
}
//
Any help would be nice
Thanks… Happy Christmas ![]()