void OnMouseDrag() { // only update the transform of this rope fragment if it is moveable if (ropeModel.IsFragmentMoveable(gameObject)) { Vector3 updatedPosition = offset + Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); // retain the y and z coordinates of the rope fragment, // as we want a simple user control of moving fragments only in x axis updatedPosition.y = transform.position.y; updatedPosition.z = transform.position.z; ropeModel.MoveRope(gameObject, updatedPosition); } }