Strange Behavior with Hit.point

I am trying to adjust the position of a cursor (a transparent 3D cube) to where the mouse is pointing on a plane however, the cursor is initially set at the hit.point but begins to travel up the ray towards the camera. The strange thing is that it worked fine then suddenly starting to exhibit the strange behavior as stated with no changes to the code, cursor, camera or plane object. The intended behavior is to have the cursor follow the mouse and attach itself to the plane much like an rts cursor.

public class mouse_selection : MonoBehaviour
{
    private Ray ray;
    private RaycastHit hit;

    public GameObject cursor;

    void Start()
    {
        cursor = Instantiate(cursor);
    }

	void Update ()
    {
        ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray,out hit,Mathf.Infinity))
        {
            cursor.transform.position = hit.point;
        }
    }
}

Fixed it! The cursor had a collider component causing this ‘flying up’ behavior as the hit.point would be constantly on top of the cursor. One solution would be to check for what collider it is hitting or to remove the collider all together from the object.