For Each events

Special Event Description

A “For Each” event is a special event that takes an object as a parameter. Then, during the game, for every instance of the object, the conditions and actions will be repeated.

In many cases, you don't need to use “For Each” events. This is because conditions and actions automatically run on all instances of an object. However, if you need to make sure that your conditions and actions are run independently on every instance, you should use a “For Each” event.

Adding special events to the project is completed the same way as adding a standard event, as described here.


When to use it

Consider the example below. When the player is in a collision with an object called “KillAllEnemyBonus”, we set the “life” variable of all enemies to 0. We also want to create a special kind of explosion at the position of each enemy. We need a “For Each” event to accomplish this. Otherwise, a single explosion would be created at the position of only the first enemy:

For each child variable (of a structure or array)

There is a special version of “For Each” that can be used to loop through the child variables of a structure variable. The “For Each Child Variable” event enables conditions and actions to be run on all of the child variables under a structure variable (or an array).

This event will store the value of each child variable (as a string or number) and the name of the child variable (as a string) into scene variables. The names of these scene variables are defined in the event parameters.


  • Define a structure variable (Fruits) with multiple child variables (Apple, Avocado, Banana)

  • Loop through the child objects and change the text to show the name and value of the child object.

  • The game preview will shows the correct values