I started to learn about Unity, and I have a problem with the Raycasting. So I have this code
if(Physics.Raycast(cam.position,cam.forward,out hit,100f,layer)){
Debug.Log(hit.point);
if(hit.transform!=this.transform){
showPreview(hit);
print(hit.transform.name);
}
}
and it works fine with objects and anything else, except the terrain. If the terrain is Flat, the raycast doesn't detect it, but if I make some mountains it works fine. Flat terrain, zero log / Tiny hill, it detects I tried to change the distance, but it didn't work.