Question by
ronlantajo · Nov 08, 2015 at 10:34 AM ·
inputtouchtouch controlstouching
Hi guys, this code controls my object with the use of a mouse to drag it, but I want to use a touch control in able to drag the object. Can anyone help me? Thanks
void OnMouseDrag (){ Vector3 mouseposition = new Vector3 (Input.touches.x, Input.mousePosition.y, distance); Vector3 objposition = Camera.main.ScreenToWorldPoint (mouseposition); objposition.x = Mathf.Clamp (objposition.x, -1.98f, 2.04f); objposition.y = Mathf.Clamp (objposition.y, -4.05f, 3.72f); transform.position = objposition;
Comment
Please use the code formatting tool when posting code to make it more readable.