hi folks,
i want to drag 2d objects, but not by clicking on it, i want to make it drag by clicking any point in the game screen, is that possible? Can you please help me guys for that, i wrote this code but its not working:
using UnityEngine;
using System.Collections;
public class drag2d : MonoBehaviour {
float x;
float y;
// Update is called once per frame
void Update(){
x = Input.mousePosition.x;
y = Input.mousePosition.y;
}
void OnMouseDrag(){
transform.position = Camera.main.ScreenToWorldPoint(new Vector3(x,y,10.0f));
}
}