unity realistically drag rigidbody2d mouse code example
Example: how to drag a 2d rigidbody in unity
// add this to your player. Make sure there is a rigidbody2d attached to it. private Vector2 direction; public float force = 1000; private Rigidbody2D r; void Start () { r = transform.GetComponent <Rigidbody2D> (); } void Update { if (Input.touchCount > 0) { target = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); direction = (target.transform.position - transform.position).normalized; r.AddForce (direction * Time.deltaTime * force); } }