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"

How to properly use delays?

alt text

I have this Bubble Sorting Algorithm implemented using the blueprints. Basically the process is I spawn objects with randomly generated integers. Get all of them and store in an array, do the sorting and swap the actor location accordingly.

I have to use delays or something to make the whole process slower so the swapping that's happening are visible. I have tried using delays in the while and for loop. the logic for the delay is for example duration is set to 1 second. for each loop is 1 second delay, the while loop since its nesting the for loop is 1 second number of elements 1.5. but the delay still does not work properly.

Any other suggestions? optimizations? fixes on the actual code?

Here is my swap Loc function alt text

and Here is my get Loc function alt text

Product Version: UE 4.18
Tags:
capture.png (309.9 kB)
capture1.png (119.1 kB)
capture2.png (106.1 kB)
more ▼

asked Mar 31 '18 at 05:18 AM in Blueprint Scripting

avatar image

Celestria
3 1 1

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

2 answers: sort voted first

Delay don't stop execution of the code, delay initiate latent action, will break the thread and looping node will continue the operation, triggering another delay create new latent action. So all those latent actions will be executed on same time as it is initiated on same frame

Maybe insted of doing loop use Tick event which executes on every frame (with Delta Seconds being time passed between the frames) or use timers which you can loop

https://docs.unrealengine.com/en-us/Gameplay/HowTo/UseTimers/Blueprints

That said Arrays already have sorting functions which can sort any type that can use > operator in C++ (which you can declare and overload in C++)

more ▼

answered Mar 31 '18 at 01:03 PM

avatar image

Shadowriver
37.8k 937 172 1123

avatar image Celestria Mar 31 '18 at 03:48 PM

Ah this is very helpful thank you. Though I still have to learn how to use them and their behaviour.. any tutorials other than the documentation?

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

I have a video for a typewriter widget where I needed a custom "For Each Loop With Delay". Starting at 2:15 I go through the process of creating the custom for each loop macro. The delay is an input pin for easy access so you don't ever have to go back into the macro to change the speed at which it runs through. Hope this helps.

https://youtu.be/IoElP38g7k0

more ▼

answered Mar 31 '18 at 02:15 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image Nebula Games Inc Mar 31 '18 at 02:19 PM

The only catch is, I see in your last screen shot you have the "for each loop" in a function, this method will not work inside a function due to the delay node. You will have to bring the for each loop outside the function like I did into the event graph and call the function as part of the loop body.

(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