Creating a random Layout in Widget

Hello,

I can’t come up with a solution on how to realize this.
I am trying to essentially build a quicktravel map. The Player is in a certain spot, can choose an adjacent position and can trevel to the next Level.
My two big problems are visualisation and randomisation.
I dont wanna draw 50 versions in Photoshop and put buttons on top of it - no Problem… I’ll randomize it - or so I thought.

I don’t know if or how I can randomize the locations of the map-buttons or any widget really. There seems to be no way to get or set positions.
At least I know, that there is a “draw lines”-node. That seems quite helpful for the connections between the points, but I see no way to access/change or even remove a specific line once it was drawn. And that would be necessary for the visual style.
I also dont think that I can measure distance between widgets, wich makes me wonder on how to decide which points I want to connect and which ones are too far apart etc…

Attached there is a mockup on what I want to achieve.

Any tips or Ideas are appreciated. :slight_smile:

Kind regards

first of all, you need a Struct, containing an Array of Integers AND a single Vector2D

now you set the Struct as a variable in your Widget and make it an Array, too. This gives you a 2D Type of Int Arrays…
like that:


MyStruct[point][targets]

As you see, the Ints itself are IDs for other Points in the Array…

So, if your Player explores the Third way point, you Cann add it to the Struct array, and add new targets to that. Where each Target is the Index of another point in the Array.
The Vector2D is the 2D Position of this Point in the Widget Map.

In the OnPaint Override Function, where you should draw your lines, you simply iterate through the Struct array and draw Lines from Struct[index].vec2 to Struct[Struct[Index][target]].vec2

Measuring the Distance is now easy af… since you simply use “Distance 2D” to get the Distance between two Vector2Ds.

Removing Target Points simply means removing the lines between them.

Hey, thank you very much for your reply.
Your suggestion definitely gave me a push in the right direction. After a couple shots in the dark I managed to create a linegrid in the style I want. Still some improvements to be made, like preventing intersecting lines or points that are too close together etc. - But nothing I’ll be unable to do.

However I still do not know if I can use it the way I intend. I basically want the player to click on the next target on the map to travel there. I can draw lines, texts and boxes, but I dont think I can reposition buttons using Blueprints.I guess there is probably still the option to check if the mouse is in the general area of my Vector2d whenever the player clicks, but it would be quite unfortunate to lose all the functionality ofbutton-widgets. Any Idea, or am I missing something obvious?

Regards.

P.s…: Oh, and by the way: It took me quite a while to figure out that you can not edit arrays (remove/resize etc.) inside of a struct. At least not with blueprints. It kinda forces you to extract your Arrays into a temporary variable, perform your action and then feed it back into the struct. A little painful unfortunately.

You can freely and directly set the position (size, too and much more) of any child whose parent is a canvas panel. I’d then draw lines between the buttons, or at least use a button as a starting point - but that’s optional if you have the vectors set up already. If you do, it’d be easier to place the button at the vector’s location, of course.

Yes, you can. What’s wrong with this:

It’s a bit more involved to do so with and array of structs but quite possible as well.