Drag an object

How can i drag a n object on mouse down

OnMouseDrag()

but be careful, for some reason OnMouseDrag() is called even when your mouse is clicked but youre not actually dragging :roll:

Hope this will help uā€¦

if ( Input.GetMouseButtonDown(0) ){
if ( !m_bDrag )
{
m_vCurrentPos = Input.mousePosition;
Ray ray = Camera.main.ScreenPointToRay (m_vCurrentPos);
RaycastHit hitInfo ;

if(m_Vaccel == true){
if (Physics.Raycast (ray,out hitInfo)) {
if ( hitInfo.collider.name == ā€œā€ ) {
m_bDrag = true;
}
}
}

m_vPreviousPos = m_vCurrentPos;
}

}

from here the rest i hope u can make it out on the if condition of the m_bDrag bool check event make the object cordinate same as that of the mouse position then the object will be draged to wat ever position u point ur mouse.