For my demo project I wanted to implement some basic isometric game. I managed to detect clicks on terrain with this code:
//mouse clicks
if (Input.GetButtonDown("Fire1")) {
Ray ray = Camera.allCameras[0].ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000.0f)) {
Debug.Log("Mouse Down Hit "+hit.collider.gameObject.name);
GameObject charObj = GameObject.Find("character");
charObj.transform.LookAt(hit.point);
} //if physics
}// if Input.GetButtonDown
I wanted to detect if the ray hit a building, and added Raycast collider to all of them. But they are ignored, and only the terrain receives clicks. Any idea about what Im doing wrong?