//method that is called when the controller should pick up the nearest rigid body
    public void pickUp()
    {
        currentRigidBody = GetNearestRigidBody();
        if (!currentRigidBody)
        {
            return;
        }
        else
        {
            //if statement checking the id of the vertex:
            if (currentRigidBody.GetComponent <VertexManager>().getBaseLineParent().GetComponent <LineManager>().getNumberOfVertices() - 1 == currentRigidBody.GetComponent <VertexManager>().getVertexID())
            {
                //if the id is the last in the line, cycle the voice of the line
                currentRigidBody.GetComponent <VertexManager>().getParentsLineManager().cycleVoices();
                resetVariables();
            }
            else
            {
                //set current-XYZ variables
                currentGameObject    = currentRigidBody.gameObject;
                currentVertexManager = currentRigidBody.GetComponent <VertexManager>();
                currentVertexManager.setIsSelected(true);


                Vector3 oldPos = currentGameObject.transform.position;

                //set the rigidBody parent and position to the controller holding it.
                currentRigidBody.transform.parent   = gameObject.transform;
                currentRigidBody.transform.position = transform.position;
                fixedJoint.connectedBody            = currentRigidBody;
                currentVertexManager.onPickUp();

                //if statement to check whether the id of the vertex is editable, if it isn't, act as if a new vertex should be made:
                if (!isEditable(currentVertexManager.getVertexID(), currentVertexManager.getBaseLineParent().gameObject))
                {
                    VertexManager newlyCreatedVertexManager = addNewVertex().GetComponent <VertexManager>();
                    newlyCreatedVertexManager.moveTo(oldPos);
                }
            }
        }
    }