I have an object that is dragged by the mouse (X and Z positions) over a table, with the following simple code:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit)); pos = new Vector3(hit.point.x,myobject.transform.localScale.y/2,hit.point.z); myobject.GetComponent<Rigidbody>().MovePosition(pos);
The dragging works as expected. What I am struggling with is how can one retrieve the direction and velocity of such a movement, i.e. the direction and the velocity of that object when moved by being dragged by the mouse (I use Unity, C#). I have searched online, but only found the common ways to retrieve velocity and movement when using standard Rigidbody movement, not when dragged by the mouse.