- Home /
Question by
karthees · Nov 05, 2014 at 07:55 AM ·
movementgameobjectdragmeshcollider
Drag game object with finger
I have gameobject in the screen and i want to move the gameobject with finger. I tried to apply Mesh Collider but it's not working,
GameObject modalClone = Instantiate( modal ) as GameObject; //clone the model
modalClone.transform.localScale += new Vector3(250,250,250);
modalClone.transform.localPosition = new Vector3(0,0,0);
Comment
Answer by EvilTak · Nov 05, 2014 at 08:50 AM
You can simply get the touch using Input.GetTouch(0)
and use Camera.main.ScreenToWorldPoint
with the touch coordinates as x and y input and z input can be whatever you want. The vector3 that is returned becomes the object's world position. If you want to drag a rigidbody with forces, check out the DragRigidbody script in the Standard Assets.
Your answer
![](https://koobas.hobune.stream/wayback/20220613170754im_/https://answers.unity.com/themes/thub/images/avi.jpg)