[Solved] TerrainQuad.setHeight

Run this code:

You should see a landscape, and after a second a large hole is digged below yourself.
The bug is that the hole is much deeper than it should: this is the code of my Control:

[java]heights.add(hLocal-0.0001f);[/java]

The hole should be barely noticeable, but instead is very deep.

You may ask, why am I using a Control for modifying the heightmap? Because I want to alter it on realtime with a smooth effect.

You are adding the current height minus a small amount. Adding instead of setting.

Thanks for your help, but I want to humbly point out that you are wrong.

If I replace my code with:

[java]heights.add(-0.0001f);[/java]

Then I get an even deeper and completely flat hole. In this case, I am really setting instead of adding.

always worked fine for me…
though I see you’re not using tpf in the statement so if your framerate is very high it will dig a hole very quickly

ie try
[java]

heights.add(hLocal-(0.0001f*tpf));
[/java]
or something to that effect.

Thanks for your help, but I want to humbly point out that you are wrong.

The Control has this line:

[java] spatial.removeControl(this);[/java]

Therefore it’s executed exactly once (and besides, I’ve already tried to fiddle with tpf with no success) :frowning:

Solved! :slight_smile:

I needed to do terrain.adjustHeight! Thanks for your help! :slight_smile: