Level generation

Hi, guys I am not a newb to programming or game dev, I am however a newb to Unreal Engine from Unity work flow.
With that said I could really use some help getting started in Unreal.
I started my Adventure Fantasy game in Unity and soon realized that performance wise it was not going to work for what I wanted to achieve. I am now trying to convert the following process into Unreal.
I was creating procedurally generated levels by taking 100’s of maze map images like the one attached, randomly selecting one, randomly selecting the wall type, wall objects, floor tiles and then reading the image pixel by pixel. I would instantiate a wall where it was was black and floor where it was white.
In Unreal I am still unsure on how to achieve this. Do I write it in a C++ Class code like I wrote it in C# in Unity or do I use a Blueprint.

Sorry if this all seems really basic, its one HECK of a learning curve for sure

In Unreal you can do most things that aren’t super low level in either C++ or Blueprints with the stipulation that Blueprints are a bit less efficient. I’ve worked with some folks on a full-fledged infinite runner VR game using nothing but Blueprints, and it runs fine. However for most of the heavier proc-gen stuff like this I’ve always stuck to C++. Plus once you get in the swing of things it becomes trivially easy to tie them together. A lot of it is a matter of preference. If you are new to Unreal I found that starting with Blueprints is a great way to quickly learn the game framework.

As for this specific case, having each pixel represented by a separate mesh can get expensive really quick. You may want to look into a different approach - combine several points into lines, check for intersections, etc. In either case, you’ll want to use Instanced Static Mesh Components to render thousands of the same mesh efficiently. Check out the link attached below for a good quick start in the first answer. There are also Hierarchical Instanced Static Mesh Components, which is the same thing but with LOD support.

For reading pixel by pixel, AFAIK there isn’t really a sane way to do this in Unreal. You may be better off finding some C++ library for reading the image type you want (e.g. .PNG) and calling that code in, say, an Actor (Unreal’s equivalent of GameObject) responsible for handling spawning.

You certainly can call those generation functions in the editor. Just slap

UFUNCTION(BlueprintCallable, CallInEditor)

on the line before you declare them in your header file and the function will appear as a button on the details panel. I think though it only works if the function takes no arguments, so you can just expose the necessary values with


and write some call-in-editor wrapper function that feeds those parameters into your actual generation function. Make sure you clean everything up properly if/when you regenerate, or you’ll probably have to re open the editor.

It’ll be a bit tricky to work with the Instanced Static Meshes in the editor - you can’t select individual instances and manipulate them with gizmos, as it will just select the whole component (and all instances.) If you’re willing to make changes in the editor while the game is running, you could detect a particular instance being clicked on and then transform that instance essentially creating your own custom tools for editing the map. To preserve these changes you could save the map; that might be a bit tricky to do it as a proper .png, but you definitely could just write your ordered array of tiles/pixels to some custom binary file (see link below.) A potential plus to this is that you could include this editor in the game - you’d already be making it with all the necessary features you need to modify your entire map!