Group Variables?

Is it possible to create group variables. If not, why not? Thank you.

Not in the editor.

However, you can achieve this in the events. When you reference a variable that doesn’t exist, GDevelop creates it (on the object, scene or globally) and sets it to a default value of 0 (which translates to 0 for numbers , “0” for strings and false for boolean).

Thank you gor the info. Can you create more than one variable this way?

It’s not creating a “group” variable; it’s accessing the picked object’s variables/settings or the entire group if there’s no condition. The group is just a reference. It’s just like objects and their instances. If you use something like a collision with GroupA it will pick the colliding object(s) in the group and any actions or expressions would apply to them. You can do anything with a group that you can with the objects it contains. So, yes. As many object variables as you want.

Only objects with “Snake” as the value of their “AnimalType” variable would be rotated and have their “Counter” variable increased by 1.

1 Like

I’ve got it - you can’t make a single variable via the group interface but can add it to each object and refer to it that way.

2 Likes