Removing single element from array removes wrong element (UE5.4.4)

IronAttorney
Sun, 29 Sep 2024 18:56:53 +0000
Blueprint

I have an array of 16 player starts. I am choosing random PlayerStarts from the array to spawn in an actor per player in response to OnPostLogin() in my GameMode. I remove that PlayerStart from the array each time.

Later in repsonse to a HUD button press by the host player, I spawn in neutral actors in each of the other PlayerStarts remaining in the array.

The problem is, that the removed PlayerStarts do not correspond with the ones the connected players already claimed, infact it seems entirely random which elements get removed. The correct amount are removed, I’ve checked that thoroughly, but not the correct elements.

Below is the macro getting a random PlayerStart showing two methods I’ve tried that should both achieve the same thing:

Here is where that macro is executed and then the returned data is used to spawn the player city actor, and remove the PlayerStart from the list. I’ve tried both of the array removal methods with same buged results:

Then later this is called to fill the rest of the PlayerStarts with neutral unclaimed cities, triggered by a UI button press (and definitely way after the initial palyer cities are added) preceeded by a check of the array lenght to clarify the correct amount were remove:

After playing and pressing said button, I can click through the player starts and clearly see a lot of the time that some have no cities associated with them, and the ones with the player controlled cities often have neutral cities spawned on them aswell (the exact proportions of each issue balancing out to make 16 cities in total each time which is the correct amount). I’ve spent a while on this, and I can’t see a good reason why this simple operation should go wrong in this way.

It would obviously be insane for the array::remove() functions to be wrong after so many years of UE5 blueprints through so many versions, but I’m struggling to see what else it could be that fits the nature of this bug

10 posts - 4 participants