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"

Infinite Loop in foreachloop

Hey guys,

I'm having problems with an infinite loop being detected in my foreachloop, which I just can't understand how it becomes infinite. It's a foreachloop, fed an array from all actors of class where the maximum number should be 2000, rather less. In the foreachloop are only branches, nothing that could go on infinitely, by far not.

Does anyone see a problem within this script? Thank you for every helpful hint! alt text

Product Version: UE 4.19
Tags:
part1.png (311.5 kB)
part2.png (395.5 kB)
part3.png (310.5 kB)
more ▼

asked Apr 14 '18 at 06:10 PM in Blueprint Scripting

avatar image

Nickcha
0 2 6

avatar image joessu Apr 14 '18 at 06:27 PM

At least in some programming languages, manipulating the array of objects you are looping through in the loop itself can cause foreach to not work correctly. Maybe try marking them for being destroyed and then have a separate loop for destroying them that is based on a count or something.

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

1 answer: sort voted first

Based on what I'm seeing, you could just use a ForLoop instead, and set the Last Index to 2000.

I doubt the Counter is the real problem though. Base on what I'm seeing, I think it's being caused by the fact that you have one loop inside another loop, and the internal loop is being scaled inside the external loop. (Spawning object in first loop, then looping over the number of spawned objects inside that loop). It's difficult to see well enough what's going on to be sure, but that's generally a pretty messy and dangerous thing to do.

Would it be possible to just loop over all the objects after the first loop completes?

more ▼

answered Apr 14 '18 at 06:47 PM

avatar image

Grimwolf
157 15 19 27

(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