Height of Terrain

Hey,



I got a Terrain Quad, and want to add Trees and Plants on top of it. My problem is that i cannot calculate the position where i should place the models, they are always either under the Terrain or way above it.



[java]tree.setLocalTranslation(50f,terrain.getHeight(50, 50),50f);[/java]



terrain.getHeight(x,z) always seems to return 0.



Any advice how to obtain the height of the Terrain at a specific point?

u can use ray collision, take a look on TestTerrainCollision

1 Like

getHeight() has recently been fixed, so if you grab the latest update it will return the proper heightmap value.

Now this is the heightmap value, and not the actual height: it doesn’t take into account scale.



So as Setekh suggested, use ray collision for the most accurate height value.

1 Like

Thanks, ray collision is working fine :slight_smile: