When making a drag/drop system, I want to keep the velocity it gets dropped at when using MovePosition. But, the velocity is not updated by MovePosition. This is the code for dragging:
if (Input.GetMouseButtonUp(0))
{
dragging = false;
text.GetComponent<Text>().text = "Drag: N/A";
Debug.Log("done dragging");
Debug.Log((Camera.main.ScreenToWorldPoint(Input.mousePosition) - hitGB.transform.position).magnitude / Time.deltaTime);
if(((Camera.main.ScreenToWorldPoint(Input.mousePosition) - hitGB.transform.position).magnitude / Time.deltaTime) >= 610){
audioSource.Play();
}
hitGB = null;
}
if (dragging)
{
Vector2 mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
hitGB.GetComponent<Rigidbody2D>().MovePosition(mousePosition);
if (hitGB.transform.gameObject.name != "Item")
{
line.SetPosition(0, mousePosition);
line.SetPosition(1, hitGB.transform.position);
line.enabled = true;
}
}