He abierto una discusión sobre las Normales del terreno, pero creo que para encontrar una solución concreta necesito entender por qué tengo 2 ángulos de pendiente diferentes en el mapa. Necesito entender en el suelo donde el ángulo de inclinación supera los 35 grados. Intenté usar la función terraindata.GetStepness, pero el resultado es incorrecto. A través de Raycast y la función Vectro3.Angle tengo un resultado diferente y mucho más preciso. Como he visto varias discusiones en las que la función GetStepness se usa con éxito, no entiendo por qué tengo que tener resultados extraños. Adjunto código y capturas de pantalla. ¡Gracias a todos! Ángulo
EN LA ACTUALIZACIÓN:
RaycastHit hit; Ray raggio = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 posiz; // = new Vector3(36, 15f, 7); //if (Physics.Raycast(posiz + (Vector3.up * 5), Vector3.down, out hit, Mathf.Infinity, MyGLB_E.layer_Terreno)) if (Physics.Raycast(raggio, out hit, Mathf.Infinity, MyGLB_E.layer_Terreno)) { posiz = hit.point; Terrain at = Terrain.activeTerrain; float normalizedX, normalizedY; Vector3 normale; hPoint = hit.point; posizp = new Vector3(posiz.x, at.terrainData.GetInterpolatedHeight(posiz.x / at.terrainData.size.x, posiz.z / at.terrainData.size.z),posiz.z); normalizedX = posizp.x / at.terrainData.size.x ; normalizedY = posizp.z / at.terrainData.size.z ; normale = at.terrainData.GetInterpolatedNormal(normalizedX, normalizedY); hpointAngolo = at.terrainData.GetSteepness(normalizedX, normalizedY) ; hString = "TERRAINDDATA (Green):\n\rSTEPNESS : " + hpointAngolo.ToString() + "\n\rNMap : " + normale + "\n\rAT : " + posizp; hN = normale; normale = hit.normal; hN0 = normale; hString0 = "RAYCAST (Red)\n\rANGLE UP : " + Vector3.Angle(normale, Vector3.up).ToString() + "\n\rNMap : " + hit.normal + "\n\rAT : " + hit.point; }EN GIZMO:
GUIStyle style = new GUIStyle(GUI.skin.label); style.alignment = TextAnchor.MiddleLeft; Handles.Label(hPoint, hString0 + "\n\r\n\r" + hString, style); Gizmos.color = Color.green; Gizmos.DrawRay(posizp, hN * 1); Gizmos.color = Color.red; Gizmos.DrawRay(hPoint, hN0 * 0.5f);