Quick note:
In my game I have a lot of enemy waves attacking by moving along a path.
I create enemies and also store a ref to the enemies in a table, so I can do the collision detection with a for loop cycling through the ref table.
Because of performance issues I now want to remove destroyed enemies not only but also from the ref table. With more than 1000 enemies created the performance drops.
My question:
Is there a way to store the new created enemies in a ref tabe and “safely” remove them from this array fast! So this array can be used to do a collision check with a circle circle collision detection (not physics)?
Right now I just store every enemy in the array (means a reference) which get’s too much with a LOT of enemies. I should remove the destroyed enemies from this ref table also, but how can I do this in a fast way and still use the table to do the collision check?
I also don’t know how to get the correct index for an enemy to remove from the ref table.
When creating an enemy and giving it an index with enemy.index=x removing this enemy from the ref table with table.remove (reftable,enemy.index) will only work ONCE and the stored indexes get messed up.
How can I still remove enemies from the ref table with the correct index?
And is there a faster way to do this without using the table.remove?
