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"

How to use ForEachLoop to remove items from array?

alt text

Hello! For example of problem I created a simple Blueprint - I'm adding some elements to empty Cell_Array and then try to remove them all. But 1/2 of elements are still in Cell_Array after all. How to remove elements from Cell_Array while iteration using only blueprint scripting? What is the usual solution? Thanks!

Product Version: UE 4.8
howtoremove.jpg (465.1 kB)
more ▼

asked Aug 27 '15 at 02:49 PM in Blueprint Scripting

avatar image

454 15 13 21

avatar image Barakka Jan 08 '18 at 12:17 AM

Great Job!

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

The problem is that as you remove items from the array, it shrinks some elements passed below your current index. You can create a ForLoop to go in reverse manually.

Hope that Helps =)

more ▼

answered Aug 27 '15 at 03:00 PM

avatar image

2.3k 114 61 232

avatar image Devero Aug 27 '15 at 03:13 PM

Here is the Macro code to create your own "ForEachLoopReversed" =)

alt text

forloopreversed.jpg (192.9 kB)
avatar image TVinforest Aug 27 '15 at 03:23 PM

alt text

re.jpg (411.9 kB)
(comments are locked)
10|2000 characters needed characters left

Copy the array, now you have 2 identical arrays. Do foreach loop on either array and remove the coresponding index from the another array. Should work.

more ▼

answered Aug 27 '15 at 03:25 PM

avatar image

50 5 7 11

(comments are locked)
10|2000 characters needed characters left
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