Hi!
is it possible to read pixel value (or maybe value of every 20th pixel?) from image or texture?
I’ve got a way to generate a grid of actors which works pretty well, but I’d like to assign proper actor class for them and I thought it would be nice to be able to draw a hex map with some tool or just in paint and depending on pixel color assign an actor class to this actor.
My actors are numbered properly by their place on grid, I know how to assign them based on value… I just have no idea if it’s possible to get color info from texture or a .png or some other format. Is it even possible with blueprints?
If you don’t know solution maybe you can guide me to some other way of doing this which isn’t just filling spreadsheet with numbers (it may be good for square grid, for hex it’s not very intuitive).
Right now I just assign either grass or water randomly as well as their height as seen on this screenshoot
From what I understand you want the grid to be the same every time you load the game. I’m not sure about reading pixels from an image but I have 3 solutions that might work:
Have a button that changes the random seed then remakes the grid until you find a seed which gives you a result you’re satisfied with and lock the generation to that seed.
Create the grid based on a constant string of numbers (“1332211243…”, each number corresponds to a possible actor for the hex). So for each spawned hex, assign the actor based on the next number in the string. This way, you have full control over what actor each hex has and you can change them individually by altering the base string. This is basically Instead of reading each pixel from an image, you read each char in a string
Use the Runtime Data Table plugin to read a Google Sheets’ file, then generate the grid based on the values in the file like you suggested at the end of the question. It may not be intuitive, but so will be generating from pixels on an image.
I don’t need random seeds. I want to make into some sort of internal map editor where I make map like the one below, where brown is hill hex, green is grassland hex etc.
I don’t want to have runtime feature, just something that I can use in-editor to quickly and easily generate maps with proper hexes, heights to improve by hand further.
In my mind easiest way to implement something like this is by reading value of pixel color somewhere in the middle of every hex (that position wouldn’t be that hard to calculate if hex size was constant).
However the thing that’s stopping me is that I can’t find any way to read value of pixel on given texture, image or anything like this.
If there is no other way I’ll need to use Google Sheets, but I’d really prefer if I could do it without it - I’ve seen map generation done that way and I know it works
I got it mostly working, but I still need to fix up some math… I think my current issues are caused by rounding. For now it looks like this (there are two types of grey material - grey grid hexes are the problematic ones):