public static bool RayAdjustHeight(Ray ray, Vector3 basepoint, out float height) { height = basepoint.y; if (!VCEditor.DocumentOpen()) { return(false); } ray = VCEMath.TransformRayToIsoCoord(ray); if (Mathf.Abs(ray.direction.x) < 0.001f && Mathf.Abs(ray.direction.z) < 0.001f) { return(false); } else { Vector3 horz = Vector3.Cross(Vector3.up, ray.direction).normalized; Plane ray_plane = new Plane(ray.origin, ray.GetPoint(10), ray.origin + horz * 10); Ray vert = new Ray(basepoint + Vector3.up * 2000, Vector3.down); float enter = 0; if (ray_plane.Raycast(vert, out enter)) { height = vert.GetPoint(enter).y; return(true); } else { return(false); } } }