Download

Map Generator 2.0 - Please Critique!

Hey ivanesses I like what you are doing. :slight_smile:

I don’t have the editor on the computer and I haven’t used construction script in a few months, but I might be able to help.

Can you use Spawn Actor From Class in construction script? I know you can in the Event Graph, but I guess you don’t want to spawn the actors at runtime?

Thank you for reply! (I wonder why my notifications does not work in the forum and in Q&A)
Yes, I can spawn actors in Editor but they are not separate to edit each individually.
I created BP Actor “TEST” and via Construction Script called “Add ChildActorComponenet” twice to spawn another Instance of the class BP. But it is not useful because It is not possible to separate actors (selecting individual actor to tune it’s parameters) http://snag.gy/YATfT.jpg

So, if you can’t use use Spawn Actor From Class to spawn your BP actors, you could possibly use the method that I use.

I store the location of each tile in an Array. I also store each separate piece of information in a separate array, so I have I think 6-7 arrays currently and it may grow to a few more at a minimum.

What happens is that when I want to update a tile, I change the values at that tile’s index which is the same on all arrays, and I make the update. Then, I Clear all Instances and regenerate the entire map with the updated arrays. Currently this is seamless. So basically I can change a forest to a tundra by right clicking the tile and this uses instanced meshes which do not contain any information themselves.

It really depends on what your requirements are though. Do you have to spawn all of these in construction script?

If I understand correctly you spawn meshes based on arrays. Are your tiles are meshes with different parameters like a color and depth? Can you empower each cell with a script?

(Any way I need to study how to make an array with that custom data (preferably how to read it from file)).

I need to spawn in construction script because I need to edit cells color and it is more obvious to see all picture at once without playing it to tune the environment.
Also worth to mention that my tiles contain scripts to interact with a Player. Every cell should have some intelligence. Maybe I’m wrong and should use your concept (which I do not 100% understand).
It is very hard to me to study your explanations without BP on my hands. Can you make at least make a short video to show what it does? Is your map just a picture w/o interaction?

Zeustiak, if you moved to 4.2 there’s the Custom Structure (Content Browser -> New -> Misc -> Structure) feature that would allow you to combine all the arrays into one array of the Structure. So if you had an array of bools, 2 of ints, 2 floats, 1 string, and 1 vector 3, you could have a Custom Structure that has a bool, 2 ints, 2 floats, 1 string, and 1 vector 3 in a nice package, and you can make an array out of them.

Also, super awesome stuff here man, I’ve been keeping up on what you’ve been working on, just been a bit too busy to pause and post.

My meshes are instances which by themselves are very limited. For me, they render and that is all I care about. What I do though, is wipe all of them when I want to make a change and spawn in type that I want displayed. So in your implementation, when your guy runs over a tile, you get that tile’s array index by referencing the location of the player or perhaps a trigger the player overlapped, and then you make changes to all the arrays that determine what that tile should be. You can pretty much do anything with those arrays as long as you can properly reference the index.

You need to edit cell colors in the editor? Or do you need to just edit the colors period while the player plays the game? That distinction is key. I can edit all my tiles in the game just using arrays and collision volumes.

Thanks for the tip, and I appreciate your support!

I actually made a struct when 4.2 came out which I use to pass all my map settings from the world data BP to the map generator BP using an interface. I am considering using structs everywhere they make sense, though I am still unsure about which cases make sense.

For instance, does it make sense performance-wise to break a struct to access 1 of 10-15 arrays to get and set one array, and then set it back into the struct? Especially if that is happening thousands and millions of times during map generation?

I suppose it is the same as asking whether I should use 3 sets of floats instead of a vector, but I generally don’t know what happens to a struct under the hood. :slight_smile:

Hey Zeustiak,

An Array of a Custom Struct shouldn’t be any less performant than a bunch of arrays, maybe Array Add processes may take a hair longer (maybe? You’d be adding less often, but each resize would be larger? I’d need a programmer to chime in). However, that’s just for the creation of the array. Accessing things should be just as quick, and they will become even more easy to use in 4.3 with the “Struct Pins” feature:

You won’t even need make/break nodes =)

Nice, I will have to check that out when 4.3 drops. I think in that case I will wait to revamp the project with struct arrays until I can use the Struct Pins at the same time.

Even more important with 4.3 is the spline editor! :slight_smile: Will start working on rivers as soon as I figure out how to use it.

I was thinking about how to create the border between different tile types such as the beaches between water and land tiles. I can think of 2 methods of creating these tile blends, though I am not sure which is more efficient.

The method that looks the best, if it can work as I need it to, is multi layered materials(I think that is what they are called) which I saw in the content examples. I did read somewhere that it could be performance expensive though, and I could need to use it up to 6 times per tile times say 30K tiles. So basically if one edge of the water hex faces a land tile, that edge would have it’s beach material revealed while the rest of the edges that don’t face land would not. Perhaps even a cliff edge for water tiles that face hills and mountains. Is it possible to do this and is it practical?

The second method, and the one that could quite a bit more work in blueprint, would be to have dozens and dozens of coast tiles and choosing the ones that fit the surrounding tiles on generation. So 1 coastal tile for every combination of water, coast or other edge types that that tile could contain. It could be as many as 15-30 different tiles just for rendering coast/beach combos. This of course would vastly increase the number of draw calls, especially if I took into account elevation, land/land borders, and so forth.

Are there any other viable options to handle tile borders?

What would be cool, is if you took that, made them a bit smaller in radius to pack them together closer, remove the coloring converting them to varied **black **and white colored intensities, save them out to a **heightmap **texture, re-import the heightmap texture image, and perform a Gaussian Blur on them to remove the edges then display it in **3D **on a flat terrain or load it into a **landscape **directly as a heightmap, and walla instant Height Map Terrain Generator yeah?

Yeah I suppose you could use it for something like that, though you wouldn’t need even a third of my generator to do it. Just use the elevation and sea level arrays and increase the number of elevations.

That is a project for someone else though.

In case anyone is interested in my current work, I have been doing a little forward thinking on much of my design in order to fine tune the resource system among other things. I have laid a framework for the tech tree as well as the government system, with a little work put into a religion framework as well. I need to foreshadow those systems a bit to probe out how they will fit with the resource system among other things.

I have also been doing some heavy reading such as: https://fenix.tecnico.ulisboa.pt/downloadFile/395139414494/dissertacao.pdf (I highly recommend it for anyone creating game maps)

Another thing I have put some thought into is rivers and fresh water representation. What I am leaning towards is that each tile will either have access to fresh water, or not. This would mean that wet and moderate tiles would have water, and give the same crop yields, and arid/semi-arid tiles would not, unless irrigated or next to a river/lake. This plays into the river system I intend to work on when the spline tool releases and it is also simple enough for players to manage.

So the water system would be represented by a number of arrays, perhaps 6. 1. Has River. 2. Has River Neighbor. 3. Has Lake. 4. Has Lake Neighbor. 5. Has Irrigation. 6. Has Fresh Water.

Each of the arrays would have multiple uses, such as using the “Has River Neighbor” array to create river valleys in the map generation, which could carve through hills and mountains the bigger they get… Level 1 river trickles out of the wet hills and mountains, level 2 is combined from 2-3 level 1 rivers and might have a 1 tile wide valley, and a level 3 river would be combined from 2-3 level 2 rivers and could have a 2-3 tile wide valley.

Also trying to decide whether rivers will exist in the center of the tile, or on the edges. Both options have advantages and disadvantages. I feel like past civ games use the edges because it is graphically easier to deal with, but I think having the rivers run through the middle, especially in hexes, allows for more natural looking river flow, as well as making the river more of a centerpiece on the map and more important to city growth. Rivers are probably the single most important terrain feature in human history, so I think they should behave that way on the map as well.

Created Resource Icons for a better visualization. They are junk, but I can pretty them up at a later date. :slight_smile:

So for the resource generation, I think I am going to head in a direction where resources are only actually spawned as the player gains the tech to work with them(as opposed to being spawned and hidden), as well as spawning additional quantities of those resources as new techs improve extraction methods down the tech tree.

So basically, Copper will spawn early in the game, and then later on, after certain techs, more Copper will spawn on the map since the player can now physically extract those deposits.

This could allow me to have resource deposits run out and disappear without penalizing players too much since more will spawn at a later point in the game(unless they run out in the middle of a war of course :slight_smile: ). That is all balance related anyway, so the details will be worked out at a later date.

Right now, I need to work out a method of spawning resources onto the map, and then spawning more resources without affecting the prior batch(s) on the map. It should be pretty easy once I wrap my head around which arrays will be affected and which I need to create to make it happen.

As with the other map settings, resources generation will be configurable in the map setup screen:

Got the resources seeding pretty well and scaling to resource map settings:

The way each resource spawns is similar to the seeds are placed, but instead of a predetermined number of seeds, each tile has a % chance to spawn a resource of any given type.

The latest iteration of the resource system is looking pretty good!

During the initial map generation, the map is seeded with all the resources that stone age man used on an important, simulated scale:

Then, as the time goes on, techs are learned, etc, both more and new resources are seeded onto the map. Here is what the map might look like in the Bronze Age:

Here are the resource seeders. Each resource spawned on the map will use 1 of these, for both initial generation and any future generations:

Here is the inside of a resource seeder:

One of the things I need to work on is making sure that when a resource is to be generated, a certain number of them actually make it on the map.

Once that is in place I can work on more methods of fine tuning controls over individual resources if that is still needed.

Looks like I may be ready to work on the river system once 4.3 rolls the spline tool out. :slight_smile:

Oh, another thing I might work on if I have time before rivers is since I learned a little about textures for the Resource Icon decals, I can put that knowledge to good use and upgrade the tile textures!

Finally recovered from a catastrophe that forced me to migrate my entire map generator to a new blueprint. Basically, I force deleted an old tile blueprint that I didn’t use anymore which made it so my map generator would no longer compile. Needless to say, nothing worked so I had to manually migrate to a BP with a new name. Don’t force delete something even if you think all of it’s references are no longer used. It might break things you can’t even see and never even touched.

Seems like everything breaks when you move it too. Copy and paste from one BP to another has unpredictable results. Some numbers get change, text renders seemed to get randomized, functions drop execution lines, it was madness. Took 8 hours to manually migrate everything, and another 3-4 to fix everything that broke.

Anyway, right before I broke the entire generator, I upgraded the materials on the tiles to make the vegetation, especially the forests and mountains, easier to tell apart.

For reference:
Arctic = Snow
Tundra = Snowy grass
Boreal Forest = Snow and trees
Coniferous Rainforest = Light green coniferous trees
Deciduous Forest = Trees with multiple shades of green.
Jungle = The fern/palm looking trees
Grassland = Green with a couple trees
Steppe = The browner grassland with no trees
Desert = The sand colored tiles
Arid Mountain = The red’ish rock mountain
Mountain = Rocky with snowy peak
Arctic Mountain = Completely snow covered with a little rock showing.

The hills are a little harder to tell apart, but they keep the general color of their vegetation type.

Decided to work on some tree static meshes to replace my current garbage tree tiles:

I borrowed some free tree fbx/material I found online and it was significantly easier to piece together than I first imagined. There is still a problem with the alpha channel on these materials, but I can fix that later.

I manually placed them first, and then measured and adjusted them. I may go for random placement on tile in the future, or maybe seeded random who knows. If I can keep individual trees that would be great, otherwise I may have to move to forest meshes in the future.

Tomorrow I will do the same for hills to take the Z vector measurements, and then after that I will work out a system for spawning and respawning them in game. :slight_smile:

Got the trees generating fairly well. Starting to look like an actual map. :slight_smile:

Right now I have the trees generating on a grid, but I am contemplating ways to make that happen semi-randomly while still keeping most of the tile tree covered. Easier on plains than on the hills, but should be doable either way.

Given the placement method of the trees I should be able to account for rivers, roads, etc fairly easily.

Looks good.

Thanks. Let me know if you see any area for improvement or know of any systems that might make the generator better. :slight_smile: