Ability for the Group and Object parameter to allow expressions or at least variables

Dear Gdevelop team,

I made the below post some days ag, and I was wondering if it’s possible to add in GDevelop.

To explain it quickly.

Imagine you have 3-5 groups, each containing hundreds of objects, which are doing many similar things.

The objects are characters with their own stats, animations, behaviors etc.

Say GroupA, GroupB, GroupC, GroupD, GroupE

Now in the game you deciede to make a team with objects from GroupA, GroupC and GroupE

In the following scene, you want to calculate their damage. (The damage of each individual character is stored inside their object’s variables)

So you do this.

image

Now, because there are characters from other groups, you will need to add this action 2 more times in your game, once for each group. 5 times total if you have 5 groups or even more.

All this, just because you can’t put a variable in the group’s place. You have to either select a group from before in the editor or an object.

GroupA.BasicStats[PNGS.Animation::Index()].ATK * OWNED_PNGS[ACTIVE_PNG[“Selected Png Set”]][PNGS.Animation::Name()].MasterLevel

If we had the ability to add a variable that equals the currently selected group or object name, we wouldn’t need to add this event so many times. We could just calculate the damage for GroupA, then change the group name variable to GroupC, GroupE dynamically, and calculate everything with one event.

Maybe it could be an expression that forces the engine to use the following value as a reference to an object’s or group name.

Readasobject = The expression
Active group = The variable that stores the name of the group, where the currently selected object(in-game) belongs to.

Readasobject::ActiveGroup.BasicStats[PNGS.Animation::Index()].ATK * OWNED_PNGS[ACTIVE_PNG[“Selected Png Set”]][PNGS.Animation::Name()].MasterLevel

Same thing when you create objects.

Here, you are forced to select a group; you can’t put a variable that includes the name of the group, to create objects from different groups by using only 1 event.

This thing could be useful if you are working on projects with MANY groups, that include MANY objects, and you don’t want to engine to search through a list of 1000 objects. Or have different events, just to read from this certain group.

Instead, you can break it down to 200 per group, while using the same number of events.

I’m not really good at coding, so I don’t know if this is possible to do in GDevelop. But I think it would be a good option to have, especially for bigger projects. The more options, the better.

I hope I made myself clear enough.

I got no reply T-T

So I will try to explain is as easily as I can.

I just want to know if this will ever be possible in Gdevelop.

Huge disclaimer that I’m going off memory on a conversation from like 4 years ago:

As far as I know that will never be possible because of how group names (and object names) are not strings but references. It is also why you can not use expressions for a top level variable name in a condition or action and can only use them for child variables.

The action itself only works because it is treating the group as the reference and then the object name as if it was a child. The group has to be the hard reference point.

1 Like

Thanks for the reply @Silver-Streak

That’s a shame, but good to know.

I’ll think of alternatives ways to handle my groups.

1 Like