1. As the title says.. I want to get the ground height from x & z vectors.

    I only know one thing .. that it has to do with RayCast nothing more.
    I've searched unity forums but i didnt find what i was searching for.

    Thanks for any help,
    PaiN
     
  2. Code:
            private static LayerMask GROUND_MASKS = LayerMask.GetMask("Terrain", "World", "Construction");
    //Credit: Wulf
            static Vector3 GetGroundPosition(Vector3 sourcePos)
            {
                RaycastHit hitInfo;            if (Physics.Raycast(sourcePos, Vector3.down, out hitInfo, GROUND_MASKS))
                {
                    sourcePos.y = hitInfo.point.y;
                }
                sourcePos.y = Mathf.Max(sourcePos.y, TerrainMeta.HeightMap.GetHeight(sourcePos));
                return sourcePos;
            }
     
  3. Wulf

    Wulf Community Admin

    The originally was technically from Nogrod, that's just my modified version. :p
     
  4. I will just add both ;x