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"

Constant array

I have a list of 35 predefined values. I want to pick a random value from this list and use it in my game. What is the best way to implement this?

I can create a Switch node with 35 outputs and 35 Set nodes. But it looks too complicated.

Also I can create an array variable in one of my actors and fill it with default values. But in this case, I suspect all instances of this actor will have a copy of this array. It looks not very good because all copies will be identical. Or I am wrong and constant variables are not copied to instances of a class and have only one instance per class?

Product Version: UE 4.22
more ▼

asked Apr 27 '19 at 03:59 AM in Blueprint Scripting

avatar image

10 1 3

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

1 answer: sort voted first

make array with those 35 predefined values, get array length - random int - get from the array a copy or reference (whichever you fancy)...

you are right that every instance will have this array though with the predefined values, so maybe you can just put this array in the gamemode or some actor that only has 1 instance and can be referenced..

note: maybe if you tell us what are you trying to do maybe we can help you better...

more ▼

answered Apr 27 '19 at 04:07 AM

avatar image

224 5 10 15

(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