Looping happens so quickly it breaks?

Hi.

I built a game using UE 4.7P8. In this game i had a loop event that picks random points. And it worked 100%.
So i built another game using the same method in UE4.7.1

However now it does not work. I have spend the entire day now… roughly 16 hours straight trying to solve this. And i am at a point now where i am thinking this has to be a bug.
Or i am overworked and a little burned out.

I need fresh eyes on this.

Basically i printed the world delta seconds and it appears that each loop happens at the exact same time. Though its possible that it just happens so quickly the delta seconds cannot display the micro fractions in which it happens.
Anyway.
I keep getting the same values. Even though theoretically it should not even be possible.
Its busy driving me up the wall.

Keep in mind i haven’t slept more than 4 hours a night for the past week.

Proof of same values


According to this. It should not be capable of selecting the same value. Because that value has been deleted from the array.
And yet… somehow it just gets the same value. Assuming it is because the loops all happen at the exact same time.

I have created custom loops with delays… i have literally spent 16 hours straight now creating, and recreating different methods to eliminate same values from popping up.
And as stated. I have this working in an earlier version of UE4 4.7P8 Build.

Please tell me i am doing something stupid. Please.

Maybe its 4.7.1 because ive nearly also torn my hair out over a number of things that worked in preview 8 but not in 4.7.1…if that is the case they should fix it soon

I’ve looked into this and it seems to be that the array is resizing although maybe the array being used is actually a temporary copy of the original. Instead of using Remove Index to make sure you don’t retrieve the same value twice, use shuffle and then call each index of the shuffled array until the end of the array is reached and every number will have been called just once.

Hi.

That’s a great solution. Clean and simple.

@Garner
If you ever in SA let me know. Will buy you a beer.
Tried this.

Much simpler logic. No more spawning on top issues, or other bugs.
Thanks

isnt the RemoveIndex function generating a new random number here after the SpawnActor node? because it re-evaluates the RandomIntegerInRange node AFTER the SpawnActor has executed? so you end up removing different entries than used for spawning and get the same value for the next SpawnActor again because it wasnt removed in the previous loop? i usually store a random number in a local variable because of that, or use a non-pure function to be really sure the Random node doesnt re-evaluate…

Yes you are right. Before i implemented to other solution from Garner i printed to random int values and discovered it re-evaluates the random int. This caused this issue i was having. Because even though it gets Index1 now… after the spawn it would remove Index 2, or 3 etc.

so how could that work 100% in 4.7p8? bug? :smiley:

hah. I have no idea. My setup was a little bit different but in theory should be the same?
Maybe in the other game the loop executed quicker and did not have time to re-evaluate? But it always gets the same value through out
But yes. Think im just tired at the moment. Was struggling with that issue too long. Easier to cast stones :stuck_out_tongue:

84f73b957fc4ede74be7299327a3f2169a32d3f2.jpeg

Well the for loop isn’t actually waiting until the execution of a loop body finished so this can very well be a break point. To be safe you should hook up something of your own real quick which takes this into consideration (maybe just copy and modify the forloop macro) so you ruled this issue out.

Though I would strongly suggest Garners approach. Maybe not exactly. It seems like you just want a set amount of iterations through the loop but a simple shuffle and then just getting the entry in your array with the index of the loop index should do exactly what you want. If that’s still not working take a look in your incoming array to double check if it actually contains all those different locations you wanted… maybe setting it new to static values right before this loop just to make sure.

And if that still bugs… well. All you can do right now is filing a bug report.

Cheers :slight_smile:

Garners solution did what i needed in this instance.
The bug is / was between the keyboard and the screen.

LOL … as least you got it sorted and we all learnt from Garner … very cool. 8-}