How to determine the number of instantiated objects

Hi,

I want:

After two objects collide, one of them should be removed and replaced with a random number of other objects. Is there a way to do this?

Is the any way to do this?

thanks,

This will randomly generate 1-10 coins at random positions on the screen:

1 Like

Thanks,
You are right.

But I think the problem still remains. In this case, if this collision happens to several objects, this event will happen only once. But my intention is that this event falls for each of the objects.

What is your idea about this code?
Do you think this is correct?

Hi!

The code you provided deletes all Boxes in screen when Circle is colliding any of them. Is that the purpose? Or maybe so that only the colliding box is deleted? In that case @MrMen code is correct, the first For Each event (where you Delete the Box) is not needed.

Could this be helpful? The link below leads to Asteroid game (WASD + Space for shooting), and when the bullet hits the asteroid, the original asteroid is deleted and two smaller asteroids are created to the same position.

I want an event to occur when the circle collides with any box.

Then put a Repeat for each box object as a subevent of the first event, move the delete action into that new event, and make the Repeat Random(10) times event a subevent of the new event.

Something like:

This will only repeat for the boxes that meet the conditions in the first event.

1 Like