Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda