Converting Terrain height into a World Y Coordinate

I’m Trying to place an object on a procedural terrain programatically.

So I’m generating an X and Z coordinate for the object within the bounds of my terrain, but the trouble is making use of the terrain’s height. Currently I’ve got it in a heightmap (rather than sampling each terrain component every time) but the values need to be converted into World space before I can use them to place an object.

Anyone know how I can do this?

Much appreciated!

Terrain.SampleHeight

After fighting with SampleHeight continually giving me the wrong value, I switched and decided to use a raycast, then instantiated at the point it hit the terrain.
Some validation is needed to ensure you don’t add an object on top of another, but it was much quicker and easier to code and deal with this way.