To get right to the point, I’m developing a top-down 2D tactical/strategy game.
I need to know how to get 2D terrain elevation into a map. For reference, see the below screenshot from Close Combat: Gateway to Caen to get a clearer picture of the type of game this is going to be as far as the 2D elevation.

It’s a puzzle I’ve been trying to wrap my head around for a while now. Any help you guys can give me would much appreciated. I don’t want to have to switch to 3D unless it’s absolutely necessary. It would increase my development costs and throw a bundle of expenses at me that I don’t want to have to take on. FYI, the battlefield is procedurally generated. If that prevents an efficient solution, I’ll look at another method for the maps. Either way, this 2D elevation thing is irritating the crap out of me lol
So I’ve been trying to think about something similar to this for a little while too. Do you want to display a kind of 3D terrain, where different heights are actually visible in 3D in the terrain? Or do you just want different portions of a completely flat 2D map to have different elevations in your game?
Completely flat 2D map, like the way Close Combat did it. I thought about using heightmaps to do that, without utilizing it for 3D terrain, where different shades of pixels on the heightmap correlate to an elevation, but I’m not even sure if something like that is possible at all. It’d be an awesome idea if that sort of thing works out, because it’s possible to procedurally generate a heightmap, and being able to procedurally generate a heightmap and utilize it for 2D terrain elevation coding would be an all-in-one package, so to speak.
I don’t want to do 3D terrain, because 3D terrain equals 3D models, which equals high costs for a modeler. Is that possible? Using a heightmap for flat 2D image terrain coding, instead of using it to make 3D terrain?
Thanks for the reply, by the way!
I guess you don’t want to use your own custom data structure like an array or something to represent height?
Oh, sure. I’m planning on defining the elevations themselves, identifying the integers as “Elev1”, 'Elev2" and so on for each level of elevation. The problem I’m having is coding the terrain texture, itself, with the elements of the array.
Hi, I am not sure if this will help but have you considered trying to achieve different heights using the sortingOrder on the sprite renderer? might be worth looking into. Unity - Scripting API: Renderer.sortingOrder
It’s an option I can look into, but I don’t know how much accuracy I’d be able to achieve with it. My project is realism intensive, with a high degree of accuracy required, but I can nonetheless look at it as an option. Regardless, thank you. I’m looking into using a heightmap as an image and code elevation onto it, rather than using it to create 3D terrain. I’ll have to see how that turns out, as well. Whichever one gives me the most flexibility.
There is no reason you would not be able to achieve a high degree of accuracy using different layers and sorting orders combined with 2D colliders and triggers. After all that’s what they designed for. However I think you may be trying to over complicate what you’re doing by repurposing an iheritantly 3d thing for a 2d use. I wish you good luck though;) it will be interesting if you get it too work
1 Like