using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
float distance = 10f;
Rigidbody2D rb;
Animator anim;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
void OnMouseDrag()
{
rb.mass = 0.0001f;
rb.gravityScale = 0;
Vector3 mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
Vector3 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);
transform.position = objPosition;
anim.enabled = false;
}
void OnMouseUp()
{
rb.mass = 1f;
rb.gravityScale = 1;
anim.enabled = true;
}
}
https://assetstore.unity.com/packages/tools/camera...