How to get altitude above terrain

I’m trying to build a simple flight simulation game, I have my own Flight Model and I created a C++ class that receive the current position and attitude from my Flight Model.

In order to be able to land, I need to know the altitude above terrain to understand when I’m getting closer to it.

With the following blueprint I’m able to get the altitude from sea level. (MRMask is the actor representing my aircraft)

But how can I get the altitude over the terrain?

Hi @Raffaele_Bortoli, welcome to the forum!

I would recommend doing a Line Trace from your plane actor down towards the terrain. This page includes some useful information about line traces. When the line trace hits something, you can use the Out Hit location and transform that location into longitude/latitude/height. The z vector of the result will be the altitude at the location queried.


Thank you Alex,

I manage to get it to work, I followed the instruction from the “Line Trace” example, but I simplied the computation by providing the second point for Hit Detection via C++, I’m using UE5 and the vector approach was not working exactly as supposed to be.