// Method to get the character at the mouse position public static Character GetCharacterAtMouse() { Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(cameraRay); foreach (RaycastHit hit in hits) { BaseController controller = hit.collider.gameObject.GetComponent <BaseController>(); if (controller != null) { switch (controller.GetType().Name) { case "MinionController": return(controller.As <MinionController>().Minion); case "HeroController": return(controller.As <HeroController>().Hero); } } } return(null); }