Hi,
I am using the following script to drag a 2D image arround within a min and max position value (basically a map).
public void OnDrag(PointerEventData eventData)
{
transform.localPosition += (Vector3)eventData.delta * 2f;
}
void Update()
{
Vector3 currentPosition = transform.localPosition;
currentPosition.y = Mathf.Clamp(currentPosition.y, minY, maxY);
currentPosition.x = Mathf.Clamp(currentPosition.x, minX, maxX);
transform.localPosition = currentPosition;
}
I would like to not have the image come to a hard stop after letting go but smoothly slow it down over like 1 or 2 seconds.
Any help how to achieve this is much appreciated.
Thanks in advance!