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"

Two dimensional array

Hey !

I would like to know if there's any two dimensional array in Blueprint scripting. I looked all over the official documentation and I only found that Array is one dimension only.

Thanks in advance !

Product Version: Not Selected
Tags:
more ▼

asked Mar 01 '15 at 09:26 PM in Blueprint Scripting

avatar image

Atemu
48 7 7 16

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

4 answers: sort voted first

Just as small heads up.

You can use an array of structs containing another array of another variable.

So two dimensional is very much possible. I'm not quite sure how it handles more dimensions than that though as I've never tested it but I can't imagine that it'd just break.

Cheers

more ▼

answered Mar 02 '15 at 12:21 AM

avatar image

Erasio
5.9k 291 86 293

avatar image sick Feb 18 '16 at 07:03 PM

It reminds me of hack used back in UnrealScript :D but yes, it's viable

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

i think he got result already, but for people who may find this, solution is really simple:

  1. make 1 structure blueprint and add into it only 1 variable array of base type you need (integers for example)

  2. make 2 array variables, first should have type of you sturuct, second same like in your structure

  3. don't use "set array item", because somehow it makes your arrays "read only", so to fill your 2d array with values you must use "add" for arrays

here's screenshots:

filling such 2D array

https://yadi.sk/i/APvDE0-qiBun9

get 2D array elements like [index1][index2] and printing values

https://yadi.sk/i/DydW8RuiiBups

see how printing look in game

https://yadi.sk/i/S-Fz5cCtiBuw8

what i didn't try:

set value in 2d array at already exist index (actually we didn't need it for our purpose, because generation of heigh map doesn't require changing after first fill), but i will try use "set array item" to see is i can set value of already exist 2d array element like [row1][column2]

more ▼

answered Jul 30 '15 at 11:14 PM

avatar image

happyhorror
576 54 46 72

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

UE4 reflection system does not support array in array (even in C++, regardless of fact that C++ allows to do so), so it's impossible to make multi dimensional array. But there very simple workarounds which makes single dimension array to work like two dimensional array, by playing allocation numbers. If one dimension has static size, you can multiply that size in allocator by number of y postions, like this:

x+(x_size*y)

Ofcorse you need to watch out to x not being higher or same then x_size or else it will read or set other y row. You can make functions to make it a lot cleaner and simpler

more ▼

answered Mar 01 '15 at 10:46 PM

avatar image

Shadowriver
37.2k 936 172 1116

avatar image Atemu Mar 01 '15 at 10:53 PM

That's weird :/ I thought of doing it in C++ but if you say that it's the same problem than in Blueprint then I'll go for the one dimension array. Thank you for the tips ;)

Do you know if this will be added in the future ?

avatar image Shadowriver Mar 02 '15 at 12:41 AM

Erasio solution seems better, i forgot you could do that ;]

avatar image HollingsworthDan Aug 28 '18 at 11:15 PM

Apparently this is still an issue. Has no one written any recursion before?

I have..

TMap> MyTableOfArrays;

I suppose I should try and do this with a single TArray?

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

answered Jun 16 '19 at 08:41 AM

avatar image

Saurabh0190
1 1 3 3

(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