How to properly use delays?
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
and Here is my get Loc function
asked Mar 31 '18 at 05:18 AM in Blueprint Scripting
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
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++)
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.
answered Mar 31 '18 at 02:15 PM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here