Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!