private void OnMouseDown() { //If the character is clicked with left mouse button if (mySelectionController.currentlySelectedCharacter != gameObject && mySelectionController.currentlySelectedCharacter != null) { mySelectionController.DeselectCharacter(); } var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { var selection = hit.transform; if (selection.CompareTag(selectableTag)) { var selectionRenderer = selection.GetComponent <Renderer>(); if (selectionRenderer != null) { selectionRenderer.material = highlightMaterial; } } } isSelected = true; mySelectionController.SelectCharacter(gameObject); }