[Blueprint] variable to reference object

hi !
i want to change an object texture to a random texture.
all the textures are “named” as numbers (0001, 0002 etc…).
i generate a random int and then…
converting it into a string is not enough nor is converting that string to asset reference (“not compatible with texture reference”)

so, is there a way to concatenate a var and feed it as a reference ?

So, I don’t think it’s possible do it from string. It’s not like html where you can dynamically load content and stuff it in.

The key is to make an array of textures at the begin play or constructor and then pick a random in the array before assigning to it to your set texture parameter value. It will give you the maximum flexibility later because you can compress those textures independently in the Editor.

That said if you really want to use a random int instead, nothing stops you from finding that int as string in the array…

Hope this helps :slight_smile:

ty , i suppose ill go the array route for the time being. Still, the old habit of forming asset names thru variable is sticking with me and i’d really like to know what is possible to do with ue4 in that regard.

Create an array called Texture Reference, set it to Texture variable type. Create Texture variable, set it to Texture type. Set up all the variables and populate the array. Then use a random integer to pull a random value out of the array. Something like this:

yup did that, kyle suggested the same thing. it worked of course, but i miss the dynamic mashing up of vars to call up references. There is a way… i’m sure !

yeah the engine needs references of those assets to produce the build.