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:

https://playground.babylonjs.com/#95PXRY#222

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 (babylonjs.com)

3 Likes

Thanks, Cedric, this seems to work.

https://playground.babylonjs.com/#95PXRY#225

1 Like