Spawing a Grid based on landscape.

I’m not at my computer at the moment, so I can’t provide the exact blueprint I used.
I created a function that would receive the xy, and based on this blueprint:

I created a modified version which was supposed to return the z. It worked to a certain point, but the position the linetrace as getting was wrong, so the tiles were being placed based in other location then the one they spawned.