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"

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. 

Why am I getting infinite loops?

I am trying to do some cave generation but for some reason whenever I run these blueprints I get an infinite loop in each one.

alt text In the above I get an infinite loop in the second for each loop even though it's not doing anything at the moment. I have checked the startY and endY values and startY is always less than endY.

alt text In the above I get an infinite loop in the ForEachLoop but when I disconnect the loop from the switch statement I no longer get an infinite loop.

Product Version: UE 4.9
Tags:
more ▼

asked Sep 25 '15 at 06:13 AM in Blueprint Scripting

avatar image

NecroTheif
43 5 5 7

avatar image Timmeh_ZA Sep 25 '15 at 05:58 PM

have you tried placing a break point (F9) and stepping through the execution?

avatar image NecroTheif Sep 25 '15 at 06:07 PM

I placed a break point but when I press Play it never gets caught and just crashes because of the infinite loop. No matter where I place the break point.

avatar image Timmeh_ZA Sep 25 '15 at 06:28 PM

does that not mean your crash occurs outside of the code you tested? have you checked the crash log for hints?

avatar image NecroTheif Sep 25 '15 at 08:32 PM

Not it means breakpoints aren't working, because I put a print statement in the loop and a breakpoint on that and run it and it prints but it doesn't break.

The crash log says there is an infinite loop at my two loops.

avatar image erinacea Sep 26 '15 at 09:28 AM

Just for clarification: Both of these screenshots show separate loops, right? And both are aborted as "infinite loops"?

In the first example, what happens inside the second loop? The first screenshot stops just where it gets interesting. :) How many iterations of loop 2 does it go through? (Use a Print node if you haven't done that already.)

avatar image NecroTheif Sep 26 '15 at 07:04 PM

Yes, they both are.

It crashes without doing anything in the second loop. It goes though all 25 iterations

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

2 answers: sort voted first

Infinite loop can happen due to the time it takes as well and not necessarily the issue of the code. there is a maximum number of statement per loop supported for UE4 blueprints. check this thread https://answers.unrealengine.com/questions/24788/how-to-bypass-the-loop-limit.html

although the best solution is to write large codes in C++ and make a function blueprint for them

more ▼

answered Sep 25 '15 at 02:03 PM

avatar image

plangton
357 17 20 31

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

You might be running into the Blueprint Loop limit. Although this defaults to 1000000, which should be enough for most cases, nested loops can cause you to reach the limit anyway.

You can increase the limit in the Project Settings > Engine: General Settings > Blueprints.

more ▼

answered Sep 25 '15 at 09:17 AM

avatar image

erinacea
1.8k 69 28 113

avatar image NecroTheif Sep 25 '15 at 05:49 PM

Both the outer loop and the inner loop have a max difference of 4 meaning that the max iterations between the both of them is 25.

(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