Object Picking

When a condition or action references an object, GDevelop must internally make a decision about which object(s) to affect in the scene. This process is called Object picking, and follows a few basic rules outlined in this page.

Rules

The object picking rules are as follows:

  • (1) An action or condition will, by default, apply to all instances of the referenced object in the scene.
  • (2) A condition will eliminate all objects in the scene that aren't satisfied
  • (3) There are certain special actions which can pick objects:
    • (3.1) The “Pick all instances” action will pick all instances of the referenced object in the scene
    • (3.2) The “Pick a random instance” action will pick one random instance of the referenced object in the scene
    • (3.3) The “Create an object” action will add to the list of picked objects the newly created object

Examples

Example 1: No conditions

Consider the following example:

This will, by rule (1), simply rotate all existing instances of “Object” in the scene.

Example 2: Multiple conditions

Consider the following example:

By rule (2), the first condition will pick only those objects that are being hovered over by the mouse. The second condition then picks from this the objects that have x position greater than 200.

Ultimately, only the object(s) which are hovered by the mouse and have x position greater than 200 will be rotated; all other objects will not be rotated.

Here is a chart demonstrating this:

Example 3: Pick all instances

Consider the following example:

First, by rule (2), only the instances of “Object” who are being hovered by the mouse will be picked. Then, by rule (3.1), all instances of “Object” will be picked.

The effect of this is that, when any Object is hovered, all of the Objects will rotate. Contrast this with Example 1, where only the hovered object will be rotated.