GML Puts differents object in a group (or assign a tag)

Hi everyone !

I've a question about GML, i'm young in the world of GML programming and i'm ask myself is it possible to put multiple object under a single tag ? Like if i have 6 different plateform object, can i put on them a "platform" tag ?

Thanks for your answers !


Yes, you can use parents for that ..

for example I got obj_solid that is parent for obj_wall and obj_semi .. and I give my fully solid walls obj_wall as parent while all my semi solid ones got the other one ..that way I can still find any of them with obj_solid
You can do like TailBit says, BUT if you need the parenting for something else, or if you need objects to be in multiple groups you will need to use something else. Off-hand I don't believe there is any built in feature like parenting for that, you will need to do something else with a data structure, or maybe even an array. Technically you will need probably need 2 axis of data (think of a simple x / y graph where Y is the group and X is the object. So, for something like that you would use a grid, but like I said you could also do it with a multidimensional array.

*edit, yea 2d array would do it too: language overview/401_06_arrays.html

Guest User

Parenting is how I will do it

You can put the instances in the same layer and use layer_get...
layer_id The unique ID value of the layer to get the elements from (or the layer name as a string)
Array (1D, populated with Element IDs)

var a = layer_get_all_elements(layer);
for (var i = 0; i < array_length_1d(a); i++;)
do something