Hi,
in UE 5.3.2, I’m trying to programmatically set the Brush of a UI Image element to an asset from an array, but get weirdly random results:
- There exists an array “Sprites” (type Object Reference) of a bunch of Paper Sprite object references.
- A Random Integer in Range selects a number to serve as a key for the next …
- … Get (a copy) node. This item from this array is then …
- … handed over to Set Brush Resource Object, so that the targeted Image element displays that sprite – see Blueprint below.
Expected Result
As long as I hard-code the key integer, or limit the Random Int in Range to a single number, everything works as expected: the sprite corresponding to the key gets displayed:
For the integer key “5” the sprite asset “5UHD” is indeed the monkey – everything fine.
Actual Result
But as soon as I open up the range of the Random Int in Range to > 1, the Print debug still says the right item from the array is being retrieved, but another, seemingly random from the array, is being displayed:
Index 12 is indeed the sprite asset “12UHD” – but that is actually this:
while the skull displayed is “0UHD” instead:
I’ve bashed my head against this for days now; redid the most basic version in a new Blueprint – but the inconsistency is reproducible. ; )
Do you have any idea why this happens?
Do I choose the wrong way to Set the sprite to the image element?
Or would you know of a way how to do this correctly?
(I do need to randomly pick or calculate which sprite to display during runtime; and I’d like to keep the sprites because they come from a sprite atlas texture. So far I haven’t figured out how I could use Set Brush from Atlas Interface: how to address the Atlas Region input [type Slate Texture Atlas Interface Interface].)
Any help is greatly appreciated! : )








