Array right choice for this case?

Hi,

i am Spawning enemies in 5er waves and i want every last killed enemy of every group to drop a powerup so i try this with first putting every spawned enemy into a temporary array then when the counter reached 5 the array gets written into another array and is being cleaned up and that cycles for everytime 5 is reached.
This kinda like works but not 100% sometimes the drop just doesnt happen.
So i wonder if this method is the right way because the blueprint looks terrible this way.
And its not reliably working.

I don’t know the layout of your code, but in theory you could set a variable to count on death and then create the drop and reset the variable to 0 on 5.

Edit: Okay, you edited in a picture.
…And after looking, I’m not quite sure what I’m looking at though.

well i created enough arrays for all groups
and simply counting them wouldnt suffice because i need the pickup
to spawn at the location of the last killed of every 5er group
and they also can be alive at the same time so just counting would only work
if only 5 are alive every time

Ah, when you say “5er” group I thought you meant groups of 5. You mean every 5th wave.

i mean i trace every group of 5 with 1 array to be able to check up if the killed enemy is the last one of its own group
its not every 5th wave

Okay, so, there are a lot of mobs alive at once. We will say 20. And they are “groups” of 5, but all attacking at once. Every time the final member in each group of 5 dies, you want it to drop something. But, the player could be fighting a bunch of other mobs in random order before then. Is that an accurate summary of the problem now?

yes kinda like but when realizing it doesnt work 100% i already delayed everything else for testing i pushed all other enemies back and also tested with just 2 waves and its still not reliable
if your point is about the identification thats ok i use the object names

could you help with my latest post?? My character stops for a second before jumping when I swipe up while walking.

You have arrays, so that means nothing here is random, right? Like, you know every single mob that is going to be spawned and you know which group it is in before the player plays the game?
Are the groups just a lot of copies of the same type of blueprint?

no the upper part spawns the enemy then immediately gets its display name and writes it into the temp array when the counter reaches 5 the temp array is transferred into the first group array and is also cleared and everytime 5 is reached it goes on to the next array

Hmmm…Do you know the exact number of arrays there will be before the player starts?

well at the moment i limited the whole thing to 10 waves for first testing because this
looks so wrong :smiley:
and also at the moment i just test with the first 2 waves
also in general is this the right way to do this?
after looking into the alternatives i think structs look promissing

I’m just trying to get a handle on anything that isn’t random because that is probably the part we can do the most with.

This seems more like something you could use a map for. You could map the whole array to integer keys, or you could just do integer and integer.

How about on the spawn node, each mob has an exposed on spawn variable. That variable is an int that can be used as a key to a map. When each mob is created the value part of the map (it could be another int), is counted up to 5. Then, once a value is 5, the spawning BP moves on to the next map key and counts that value to 5 and sets the exposed variable in the mob BPs to the new key.

Then, every time a mob dies, it gets the map from the spawning BP and subtracts the value tied to its key by 1. Then it checks if the value tied the key is 0, and it if it is, it spawns the powerup.

That seems roughly as convoluted as what you are already doing though.

yea i played around with a map but i didnt get the point about what you just said
i thought in a wrong way of putting the display name into the map so i didnt manage to identify the 5er groups
you got the point
ok could i also write one single array with all spawned display names check the index value
to get the map index position?
like 1-5, 6-10…

thx for the help already

i just wonder would the map be better,faster?
or just smaller blueprint wise

yay i did it thanky for your tip
now its dynamic and open end
only problem is when enemies get killed before the whole group is spawned so just make them invulnerable for 1-2 seconds


Screenshot 2023-02-20 004324