x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[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 ?

alt text

Product Version: UE 4.11
Tags:
rnd.jpg (207.3 kB)
more ▼

asked Apr 14 '16 at 05:06 AM in Blueprint Scripting

avatar image

Cyprine
10 4 6 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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 :)

more ▼

answered Apr 14 '16 at 08:20 AM

avatar image

keyle
1.8k 66 27 90

avatar image Cyprine Apr 14 '16 at 05:24 PM

ty keyle, 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.

avatar image keyle Apr 17 '16 at 09:35 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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:

alt text

capture.png (173.0 kB)
more ▼

answered Apr 15 '16 at 02:01 PM

avatar image

Nick Jackson
492 17 14 107

avatar image Cyprine Apr 17 '16 at 09:31 AM

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 !

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question