I’ve started to work on a little arpg-but-it’s-turnbased prototype recently to test out what I can achieve with blueprints.
Like most arpg type games, it’s likely that players run into situations with a lot of items on the ground which they want to pre-inspect, to see if it’s even worth picking them up.
So I’ve spent yesterday and today trying to add toggleable item-labels for all ground-items.
While displaying the names is not really a problem, the dynamic layouting of said names turned out to be a lot more difficult than I anticipated.
My current attempt that I am working with is basically a function that fires once when there is no camera movement since it takes too long to calculate while moving.
Right now it works like this:
- Iterate through all label-widgets and check if they collide with any other labels.
- if collision is detected, store them for later since we know they need to move.
- Once all collisions have been detected, I iterate through all labels with collision.
- For each colliding label, I start pushing it away from the middle in incremental steps and check if it’s still colliding with something. Which of course is yet another loop we are working with.
Once all that is done. I most of the time get some semi-acceptable result.
Video of that monstrosity in action.
But I feel like there must be a better way to do this.
Right now, I am either not experienced enough with these kind of problems, or I’ve hit a point where relearning c++ would be my best option since I suspect this graph would run a lot faster as script.
(I don’t know how to properly share this in a legible way )
So my question here is basically just.
Should I do more reading into some obscure real time rectangle packing papers or did I make something in BP that I should probably have rather done with c++.
Or did I approach this in a fundamentally wrong way. I’m very much a beginner when it comes to UE/gamedev. I’m normally more on the web-dev side of things, our rectangles don’t move that much
EDIT: After some more research I found out that I am dealing with a problem that is literally called “Automatic-Label-Placement”. This is definitely an algorithm issue not a BP issue.
I’ve yet to stumble across a paper or something that discusses speed / implementations in games but I think it got me on the right track to figure out a more efficient way to do it.
EDIT2: I found a way to make it work. I posted my solution below.