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. 

How Can I get the "WhileLoop" working?

I'm trying to use the while loop in a simple script but I get the message :

LogScript:Warning: Runaway loop detected (over 1000000 iterations) MyProjectile_C /Game/Maps/UEDPIE_0_Example_Map.Example_Map:PersistentLevel.MyProjectile_C_8 Function /Game/Blueprints/MyProjectile.MyProjectile_C:ExecuteUbergraph_MyProjectile:001D

I simply want it to execute every frame while a boolean var is true.. but it doesn't look like I know how to properly use it..

Product Version: Not Selected
more ▼

asked Mar 25 '14 at 09:05 PM in Blueprint Scripting

avatar image

31 3 4 4

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

2 answers: sort voted first

Can I request that a Blueprint function be made like the "LoopWhile" one, but only executes every tick ?

more ▼

answered Mar 27 '14 at 03:30 PM

avatar image

96 12 21 20

avatar image ReverendK May 02 '14 at 07:42 AM
  • on this. In its current state the while loop seems to just be a big fat crash button.

avatar image Joe Conley STAFF May 02 '14 at 03:07 PM

The WhileLoop is working as intended, just some case needs to be taken to ensure it is being used correctly.

Note in the documentation for WhileLoop where it states:

As with While loops in programming languages, extra care must be taken to prevent infinite loops from occurring.

Namely, if the logic executing in the while loop never sets the condition controlling the while loop to false, it will never stop executing, and you'll run into problems.

I think the functionality you're looking for in regards to something that executes once per Tick is represented by the Tick Event. If you want a function that executes exactly once per tick, you could easily accomplish that by connecting the "Event Tick" node to a function you make in your Blueprint, like so:

alt text

You can also execute a function once per tick as long as a condition is true:

alt text

Are you having trouble getting the results you're looking for from the Event Tick node?

avatar image CharlieTheTall Jun 13 '14 at 09:17 PM

You could add a small delay in the while loop so that it only executes once per frame. Hacky, but could get you what you want without crashing. I know in other scripting languages there was a command for "waitframe();"

Using tick would work, but if you're looking for this functionality and you're already doing a few things with the Tick event, it can get kind of messy.

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

The while loop will continue to execute within the same execution tick.

What you want to do is hook up an OnTick event in your Actor blueprint and then have a Branch based on your boolean var.

more ▼

answered Mar 25 '14 at 09:25 PM

avatar image

Marc Audy STAFF
2.2k 42 35 95

avatar image Chaps Mar 25 '14 at 10:40 PM

Ah ok cool I get it, thanks for the quick answer!

(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