Hello everyone!
So I implemented a very basic drag and drop system that actually reponds to physics. Is there a way to somehow cap the speed and/or drag force of an object? I looked at
My code sofar is:
private void Awake()
{
cam = Camera.main;
}
private void OnMouseDown()
{
dragOffset = new Vector2( transform.position.x, transform.position.y) - GetMousePos();
}
private void OnMouseDrag()
{
Vector2 stuff = GetMousePos() + dragOffset;
this.GetComponent<Rigidbody2D>().MovePosition(stuff);
}
Vector2 GetMousePos()
{
var mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0;
return mousePos;
}
Is there any way to do the above mentioned things? The unity documentation shows no possible solutions for this.
Wish everyone a nice day/evening!