and yet it doesn’t work.
Judging by the pic, you’ve yet to plug in an array into the loop at the bottom. Not sure if that’s just a badly timed screenshot. May be.
I have read a lot that UMG widgets can
be fussy when doing lots of
parenting/unparenting because they are
held in memory even when they are
cleared. I tried messing around with
garbage collection and that didn’t do
anything.
True, but manual Garbage Collection will work providing you do dereference the widgets. Clear variables / arrays and remove from parent (viewport is also a parent).
Bottom line, I feel like this is a
pretty typical mechanic you would see
in a game and I would be very curious
to know how someone else would
implement it better.
My current solution also just doesn’t
feel that polished, I would like it if
it could keep track of distances
dynamically and update so it’s always
in order of distance without
rebuilding the entire UI but I can’t
wrap my head around how to do that in
blueprint.
You’re approaching it correctly as far as blueprints go. It’s still a thing with UMG - one cannot insert a child where needed so you need to flip arrays all day.
- have each actor own their own widget (created once and only on request)
- sort those actors by distance
- clear the widget container and repopulate with those actors’ widgets