Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
UNITY3D : Get Stepness without Raycast

I have opened a discussion on the terrain Normals, but I think that to find a concrete solution I need to understand why I have 2 different slope angles in the map. I need to understand on the ground where the slope angle exceeds 35 degrees. I tried using the terraindata.GetStepness function, but the result is incorrect. Through Raycast and the Vectro3.Angle function I have a different and much more accurate result. Since I have seen various discussions where the GetStepness function is used successfully, I don't understand why I have to have strange results. I attach code and screenshots. Thank you all! Angle

ON UPDATE :

        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;
    }

ON 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);
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda