how to make a gameobject follow the mouse in unity code example
Example: unity object follow mouse
if (Input.GetMouseButton(1)) {
mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
transform.position = Vector2.Lerp(transform.position, mousePosition, moveSpeed);
}