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"

Loop with delay inside a function?

How to add a delay inside FOR or FOREACH loop inside a function? It seems impossible (design limitation, can't put Delay nodes inside function :( ) but how to achieve this in some workaround-way? For example: Let's say i want to, for each Bob object to say "Hello", wait 2 seconds and iterate this loop again, with another Bob saying "Hello". Effect: Every Bob on my scene will say "Hello" with 2 seconds interval. All this inside a 'MakeAllBobsSayHello' function :) How to achieve this?

Product Version: Not Selected
Tags:
more ▼

asked Apr 21 '15 at 11:15 PM in Blueprint Scripting

avatar image

Slavq
2k 153 153 204

avatar image Narghile Apr 22 '15 at 11:13 AM

SO are you using a Loop or you just want it to loop?

Narg

avatar image Slavq Apr 22 '15 at 11:26 AM

I've redesigned my question to be more specific, with an example :) So now the question is, how to make every Bob say 'hello' with 2 seconds delay inside a function? :D

avatar image me4dinosaur Jan 21 '16 at 07:19 PM

That is simple. Make a boolean which will determine if the function is supposed to be looping and on the outer node of delay, bring it back to For Each Loop.

avatar image Slavq Jan 21 '16 at 07:26 PM

This will still execute all array items (all foreach iterations) at once, because foreach loop doesn't respect Delay nodes. I've already found a solution though (with use of modified ForEach), it's in the answer :)

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

4 answers: sort voted first

There is a way to nest the "delay" within the Macro itself which I find much simpler and cleaner. Everything I have seen on this has the delay outside the macro but here I show how you can actually modify the macro to "wait" before looping so everything is self-contained.

https://youtu.be/zh8xx9abzZY

more ▼

answered Apr 08 '18 at 09:33 PM

avatar image

Nebula Games Inc
4.6k 27 9 14

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

Use a custom event, not a function.

Narg

more ▼

answered Apr 22 '15 at 11:38 AM

avatar image

Narghile
1.7k 74 38 109

avatar image Slavq Apr 22 '15 at 12:28 PM

Thanks for suggestion, that doesn't solve the problem because of FOREACH loop not respecting Delay node, but i've posted a workaround. +1 for You ^^

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

OK, i did it: First, use custom event instead a function, as @Narghile suggested. But that doesn't solve the problem, because foreach loop will not respect delay node and execute all Bobs at once. HERE, in @Erasio answer, there is an instruction how to modify for loop to respect Delay node. After modifying it this way, just setup it like this: alt text

Now, all Bobs on scene will say Hello with interval specified in Delay node :)

bobssayhello.png (88.7 kB)
more ▼

answered Apr 22 '15 at 12:27 PM

avatar image

Slavq
2k 153 153 204

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

This could be another approach: (UE4.10) -> Using "Set timer by function name" (link to the Unreal Docs).

Using this node, with the loop checked, and setting the time for 2 seconds (from your question description) will produce similar effect that will solve the task (trigger a "hello" every two seconds).

more ▼

answered Apr 02 '16 at 07:56 PM

avatar image

azennig
21 1

(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