Return distance of raytrace hit from spawned actor on the z axis

I am trying to a use raytrace to calculate the landscape surface distance so that we can generate meshes on landscapes with height irregularities via blueprints. Basically we want to tell these trees that as soon as the ray hits the landscape we want it to stop, the trees will be spawned in from above the world (Image 1) and will fall until the line trace hits the landscape so we can avoid problems like this with trees clipping in the landscape(Image 2).

Also if there is another way than making them spawn above, lower until the ray trace stops, like being able to define the landscape and tell it to spawn at the correct height like the foliage tool does with landscapes, except within blueprints that would be awesome. We want to generate these meshes via blueprints not just trees, they are just our test subject so this isn’t specific to foliage. Any help or advice would be great.

check this project

https://forums.unrealengine.com/community/community-content-tools-and-tutorials/1491686-free-procedurally-instanced-meshes

there you can find an example of objects aligned to the ground