I want to detect the hexagonal tile a unit is on upon clicking on the unit. I was thinking of using a ray cast I can't get it to work.
I'm trying to get the raycast to shoot from the bottom of the unit and change the material of the collided object.
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit)){
Debug.Log (hit);
string hitTag = hit.transform.tag;
if(hitTag == "player"){
if(Physics.Raycast(user.transform.position,Vector3.down,10)){
Debug.Log ("I'm on something!");
hit.collider.renderer.material.color = Color.red;
}
}
}
}
What might be going wrong?