How to detect surrounding terrain height for minimap (comparable to a sonar)
I am trying to think of a way to create a minimap which shows the height of the player's surrounding terrain. I've illustrated an example of what I've got in mind in the figure below.
I've got an idea about how I could go about doing this but it seems very inefficient so I was wondering whether there was a better way.
What I'm currently thinking of is placing 49 Box Colliders (for a 7x7 minimap grid) with the player in the center. I'll then check whether anything with the "Terrain" tag enters one of these colliders. If it does I'll start continuously measuring the distance of the terrain to the top of the box collider with which it is colliding. This way I'll be able to determine the height of the colliding terrain and the value which should be given to the corresponding position on the minimap. I've also illustrated this in the figure below for clarification.
This approach seems possible, but very roundabout and inefficient. I was wondering whether there was a better way to achieve the same effect.