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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Variable Integer Sorting.

I am trying to make a map blueprint that can read different values for each floor. I need a node that takes an input integer for what floor a room is on (from a ForEachLoop) and sorts each different value into separate arrays, one for each floor. The biggest issue I am having is that the amount of floors changes according to a user defined variable. Is there a node or function I can use/make to get the desired effect?

Product Version: UE 4.20
more ▼

asked Dec 13 '18 at 02:50 PM in Blueprint Scripting

avatar image

Timothy LeBlanc
14 2 2 6

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

1 answer: sort voted first

If I get it right, each room has an index that represents the floor it's on. When you launch the ForEach loop, you get that index and want to sort the rooms in accordance with that, right?

The number of floors is random, but is there a limit? If yes, you can simply use a Switch On Int, with enough output pins to cover the limit (if the number of floors is lower than the limit, the higher value pins just won't execute). I don't thick you will have dozens of floors, so that can be your choice.

more ▼

answered Dec 13 '18 at 03:12 PM

avatar image

1.8k 12 7 8

avatar image Timothy LeBlanc Dec 13 '18 at 03:24 PM

The way I have the maze/dungeon set up is that there are three integer values that are editable in-editor, a width (x), a length (y), and a height (z). On begin play, the maze is generated with rooms filling those dimensions randomly. For example, I can have it set to Width 4, Length 4, and Height 100 to generate a maze with sixteen rooms per floor and one hundred floors. I want the blueprint to find what kind of rooms and what arrangement they're in, for a given floor.

avatar image Nebula Games Inc Dec 13 '18 at 03:41 PM

I'm confused how this is a "sorting" issue. If someone enters, 10x10x10 you get 100 rooms per floor and 10 floors correct? And you want a blueprint to tell you that information based on what the user input? I am confused or you want to end up with 10 arrays of 100 rooms, 1 array for each floor?

avatar image Timothy LeBlanc Dec 13 '18 at 03:53 PM

I want the blueprint to know how the rooms are arranged so a widget could reference the variables for each room and create an accurate map for a given floor using texture 2d variables held by the room actors.

avatar image Tuerer Dec 13 '18 at 03:43 PM

Okay, let's say you have a tower 4x4x100. How are rooms generated? The generation probably starts from the bottom or from the top, I assume, so why don't you just take those width and length, multiply them, and in the course of room generation you can sort them out: first 16 are on floor 1, second 16 is on floor 2, etc.

Alternatively, is the rooms' size always the same? Can you just get the rooms by their Z location?

avatar image Timothy LeBlanc Dec 13 '18 at 03:50 PM

The blueprint finds all the locations for the rooms and puts them into an array. Then it picks a random location from that array, adds a child actor component at that location, then sets that component's class to one of thirteen identically sized rooms and removes the chosen index. This loops until the array is empty.

avatar image Tuerer Dec 13 '18 at 04:05 PM

I don't get it. If you put a random room out of 13 into every location, why do you need to get a random location? I don't think double random will be any more random than single random. You can easily start from the bottom with the same result.

avatar image Timothy LeBlanc Dec 13 '18 at 04:20 PM

I couldn't think of a non-random way to spawn the rooms at the time. It does have the same effect so I don't know how much it matters. If I can find a way to break the location array into separate arrays based on the Z value I should be able to accomplish what I'm trying to do.

avatar image Tuerer Dec 13 '18 at 04:29 PM

You should take a look at how the locations are organized in the original array. I guess there must be a way to rearrange the array by Z location.
Or you can find a room with the lowest Z value in the array, then you get all the rooms with the same Z value, add them to a separate array and remove them from the original array. Then you do the same again and again, until the original array is empty.

(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