Delete most number of spawned object

Hello all. I’m trying to make a simple board game where 12 possible icons drop on a 5x6 grid totaling 30 icons. I have figured out how to determine the most number of spawned object by using number array. now i’m stuck with how to delete the said objects to make room for the next round of drops.

ex. among 30 objects, the most number are apples which is 10. How do i delete those 10 apples? i cant seem to figure out. if anyone can suggest events to make it happen. Thanks.

I’m not sure what the issue is. What’s preventing you from deleting the apples? Are they seperate objects or the same object with different animations?

Can you use delete apple or

animation of icon equals apple
delete icon

Do the apples need to be in collision with something or in a specific position?

I wanted to test the concept. I added 15 Icon objects with an object variable named Total.

I used local variables instead of an scene ones. I wanted to be able to repeatedly test it. So, instead of deleting the icons, I changed the opacity.

My test

I originally tracked the highest count and the matching animation number but I didn’t like how it would add bias to the icon that was picked first. When there was a tie, Apples might be picked more frequently than say grapes.

Instead of the pick a random object, I though of using an array for the highest icon’s animation number but I wanted to keep it simple.

Found a rustic solution, I don’t know if it will hold up in the long run. It works for now. I just need the most number of similar icons deleted from the scene to make room for new random icons to be dropped.

Once an icon is on the floor, it adds 1 to the corresponding number array slot. After the icon counter hits a total of 30 in the scene, it will determine the max number in the array and delete the icon corresponding to it. If there are 2 icons with same max number, both of them gets deleted.

Screenshot (148)

Screenshot (147)