Change maxHeight of ground after it's created

Hi all. Alas a question that GPTChat couldn’t answer correctly. Is it possible to create a heightmap and then update its maxHeight dynamically?

Like take this PG: https://playground.babylonjs.com/#5W5B6W#138

But 10seconds after it’s created, increase the maxHeight, so that it looks like this: https://playground.babylonjs.com/#5W5B6W#144

GPTChat says to do this: ground.updateHeight(20), but that doesn’t work. Nor a variety of other things i tried. Any tips?

Hi, you can change ground scaling Y.
Like this

and apply the physicsImpostor again after update. I disabled it for demo purpose

1 Like

That’s beautiful, like it’s breathing.
I’m using the grid as if they were coordinates on a map, so it’s important that they don’t stretch. Is there anyway to redraw the ground as if it’s maxHeight had been set at a higher value from the outset?

There’s no dynamic way to update a ground mesh created by CreateGroundFromHeightMap as this function is simply a helper to generate a ground mesh.

Your best option, I think, is to create another ground mesh with a height=100 and switch to it when you need to.

2 Likes

Ah k. Got it.
I’ll give it a try with dynamic resize using yscale and then “save” by creating another mesh with new size (assuming i can map yscale to maxHeight approximately).