1. I found (somewhere) and am using the following function to get the ground (Y) position at a particular location (X,Z)...

    Code:
    Vector3 GetGroundPosition(Vector3 sourcePos)
    {  
        LayerMask GROUND_MASKS = LayerMask.GetMask("Terrain", "World", "Construction");  
        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;
    }
    Using it to teleport sometimes spawns one into rock formations.

    Does anyone know how to fix it or have a better way?

    Short of dropping the player from the sky I have no idea how to prevent this.
     
  2. Not sure, but you can remove check for LayerMask and RayCast will hit first object that he will found.
     
  3. Well there you have it. Thanks friend.