I want to drag an object to a perticular place.In case i leftI release that draggingdragged object before iI reach that perticularparticular area i want to be that,the object in the sameshould come to its initial placeplace where i start to drag. How it possible? Is there any specific motion for this?
void OnMouseDown()
{
drag = true;
//Debug.Log("haii ");
}
void OnMouseDrag()
{
if(drag)
{
var pos =Input.mousePosition;
pos.x =Mathf.Clamp(pos.x,0,Screen.width);
pos.y =Mathf.Clamp(pos.y,0,Screen.height);
if(zdist>0)
{
zdist=Vector3.Distance(Camera.main.transform.position,transform.position);
pos.z=zdist;
pos = Camera.main.ScreenToWorldPoint(pos);
transform.position =pos;
}
}
}