Drag Object with Touching
I can move my objects with this code:
using UnityEngine;
using System.Collections;
public class dragDrop : MonoBehaviour {
void Update()
{
if (Input.touchCount == 1)
{
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
Vector2 touchPos = new Vector2(wp.x, wp.y);
Collider2D coll=this.gameObject.GetComponent<Collider2D>();
if (coll == Physics2D.OverlapPoint(touchPos)&&Input.GetTouch(0).phase==TouchPhase.Moved)
{
this.transform.position=touchPos;
}
}
}
}
But the problem is when i move my finger faster object can't follow it.Any suggestions?
Comment