unity raycast to mouse position
//code for raycast Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; Physics.Raycast(ray, out hitInfo); GameObject hitObject = hitInfo.transform.root.gameObject; //code for getting a paren'ts transform private GameObject GetRoot(GameObject gameObject) { Transform t = gameObject.transform; while (t.parent != null) { t = t.parent; } return t.gameObject; }