Determine altitude from GroundMesh created with CreateGroundFromHeightMap

I am trying to determine altitude above the GroundMesh created with CreateGroundFromHeightMap (and thus be able to do collision detection with the ground).

getHeightAtCoordinates flat out doesn’t work (returns NaN), and the method with ray casting only works if I cast from a low altitude, but yields bad results if I cast from a normal altitude, as seen in the demo:

Let me take a look…

You can get valid values when calling updateCoordinateHeights when the ground is loaded. Check line 23 in this PG:

Trying to determine altitude from GroundHeightMap | Babylon.js Playground (


Thanks, Cedric, this seems to work.

1 Like