Display random object on screen.

Is there any way I can choose a random object (from a group) and display it on the screen at a certain position using an action? Please help.

AFAIK no, there is no action to do it, but you can do two things:

If there are few objects in the group (e.g. 3, 4… 5 objects), you can do:

[code]Conditions: Conditions to create the object
Actions: Do = Random(4) to the variable random_index // random_index is a random number between 0 and 4
// Sub-event 1
Conditions: Variable random_index is = 0
Actions: Create object A at position X;Y

    // Sub-event 2
    Conditions: Variable random_index is = 1
    Actions: Create object B at position X;Y

    ...[/code]

If you have a lot of objects in the group, maybe you want to make a list, a structure variable called “Group” with childs that map an index with an object name, this way:

Group 0 ObjectA 1 ObjectB 2 ObjectC ...
Now, with this long structure, you can use a simple event to get a random object from this structure, but you have to use the action to create an object from its name:

Conditions: Conditions to create the object Actions: Do = Random(50) to the variable random_index // random_index is a random number between 0 and 50 Among objects in the group YourGroup, create the object named VariableString(Group[VariableString(random_index)]) at position X;Y

1 Like

Thanks Lizard-13, your answer helped a lot!