Pokenic99
(Pokenic99)
October 27, 2020, 1:20pm
1
It is possible to randomize textures on a static mesh taking random image from an external folder?
Hi guys,
I need help to know if it is possible to make the faces of the cube change randomly with random textures from a selected folder of the pc using the blueprints.
when I press the buttons on the top left the faces will be changing in random textures.
thank you for your attention!
LogierJan
(LogierJan)
October 27, 2020, 2:19pm
2
LogierJan
(LogierJan)
October 27, 2020, 2:27pm
3
To make it random you could get all filenames with a given extension from a folder and put these into an array. From which you then randomly pick one.
The Rama plugin also contains a function that can do that for you:
JoyFileIO_GetFiles
An example:
LogierJan
(LogierJan)
October 27, 2020, 3:50pm
4
I personally only tested the get files at runtime, but I don’t see why the Load Texture wouldn’t work aswell.
Pokenic99
(Pokenic99)
October 27, 2020, 3:43pm
5
ok, and is it possible to change texture in-game in real-time?
ex. I take a photo > the photo is stored in a folder > the image will appear by pressing the button automatically in real-time
LogierJan
(LogierJan)
October 27, 2020, 6:08pm
6
Here I made a working example using a cube. (specify the correct folder for your pictures)
Then simply call the ApplyRandomTextureFromFolder function with the material index you want to change.
I would set this up in the actor that you want to change textures on. And call the function from the UI.
Pokenic99
(Pokenic99)
October 27, 2020, 5:18pm
7
ok… last question XD
where do I put these nodes?
I’m trying to put them on the button and nothing change
LogierJan
(LogierJan)
October 29, 2020, 10:32am
8
Glad it worked, please accept the answer if this resolved your problem!
Pokenic99
(Pokenic99)
October 29, 2020, 9:52am
9
I tried to replicate your blueprint but with a button of a widget but nothing happens… it says that it failed in step 2
LogierJan
(LogierJan)
October 29, 2020, 10:02am
10
That would mean there are no files with the extension “.png” in the folder you provided, since the length of the array is 0.
LogierJan
(LogierJan)
October 29, 2020, 10:09am
11
I also see I did Length - 1 , this is not needed when using Random Integer. Since it gives a number from 0 to max -1. So you’d want to remove that.
Pokenic99
(Pokenic99)
October 29, 2020, 10:24am
12
Ok! now it’s working!!
I removed the -1 integer and Inoticed the first node was wrong, I put the JOY FILE IO GET FILES instead of JOY FILE IO GET FILES AND ALL SUB FOLDERS
Thank you so much!! ^^