Can u try like this: inside update function
if (Input.GetMouseButtonDown(0))
{
// when button clicked...
gui = "no";
}
RaycastHit hit; // cast a ray from mouse pointer:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// if enemy hit...
if (Physics.Raycast(ray, out hit))
{
Debug.Log("selecting");
DeselectPlanet(); // deselect previous target (if any)...
selectedPlanet = hit.transform; // set the new one...
planetselect(); // and select it
}
↧