private void OnMouseDrag()
{
Vector3 screen_sp=new Vector3(Input.mousePosition.x,Input.mousePosition.y,screen_space.z);
Vector3 cur_pos=Camera.main.ScreenToWorldPoint(screen_sp)+offset;
if(pendulum_object.gameObject != null && pendulum_object.gameObject.rigidbody!=null)
{
transform.position=cur_pos;
Debug.Log ("Pendulum is being dragged left"+transform.position);
Debug.Log("Mouse position is:"+Input.mousePosition);
Debug.Log("Current position is:"+cur_pos);
}
}
The problem is:The dragging of game object must be restricted to the length of string. The pendulum is joint using hinge joint to the world.
dir_vector*string_length
and see what happens. I'm not sure if this is possible because I'm not familiar with Unity. This comment is all that I can suggest about your question. \$\endgroup\$