Variable inside the group name of potential objects. Instead of selecting the group

Hi guys,

So create an object from its name.

image

I was wondering if there is a way to add a variable, inside the group of potential objects section (PNG in this example) so that you can select a different group to create objects from just by changing the variable.

image

My PNG group currently has around 80 objects (game characters). While there is currently 0 lag as they are very lightweight, I don’t know for how long this will last as I plan to include a ton more. So I want to create many groups just to be safe. Besides that, I have groups with different variables and behaviours so I do need to split some of them.

I could just create different events, one for PNG group 1, PNG group 2 etc but before that I wanted to check if there is a way to avoid unnecessary code lines before I add them.

Just for clarity. Groups are a list of objects. It doesn’t affect the actual group. You can put the same object into multiple groups. It’s a reference to the object not the actual object. I’m guessing a group list uses extremely few resources.

I don’t know if they fixed create object by name but for some time you’ve been able to create an object regardless of whether it was in the group name that was used.

If you are concerned about having too many different objects. You could use the same object with different animations. They say instances are pretty efficient compared to seperate objects. If you have a lot to setup for each object or behaviors then this might be optimal.

What are your other concerns.

Edit: FYI. Object variables aren’t available until an object is added to a scene. You could use a naming system for the objects like Monster1 thru Monster7. Or some other system. And then combine the name with the number.

2 Likes

Thanks for the reply Keith.

Basically, what I want is to be able to declare the group with a variable, but it seems that no such option exists. The option is available for the object of the group, but not for the group’s name.

My basic characters are simple still images, and each has 2-3 animations (Basically one form, per animation)
My more complex characters have 1 form but many animations for their movement and actions.
This is the easiest way I could think of that would allow me to manage them without additional issues.

Hearing that groups use few resources eases my mind a bit, but I’m still a bit worried since when I click apply, I notice a small lag, and it takes a few seconds to close the group window. I don’t know what will happen once I add more than 1000.

I don’t know if they fixed create object by name but for some time you’ve been able to create an object regardless of whether it was in the group name that was used.

This is actually the thing that I want. If there is a way to create an object using a variable, without having to declare it in a group, it would help me tremendously, I think… Still thinking about the most efficient and flexible way to handle this

You can only create an object by name if it’s in a group. At least that’s how it’s supposed to work. There was a bug. If the bug still exist, I still wouldn’t use the action without the object being in the group because it might stop functioning when they fix it.

Instead of 1,000+ objects it might be more efficient to combine the images for related items into fewer objects. You could always change the animation after the object was created.

Example. When people create images for an inventory, they usually add all of the images of the possible objects into 1 object. They can then just add an object and then change the animation.

1 Like

I see, I’ll need to think about it…

Btw, I still do need to create different groups for the characters, as some of them behave very differently.

An action to create, select or reference an object based on its name (stored in a variable) would be great.

For example, here, where I calculate the damage. PNGS is still my main group, and from there, I pick the selected object (game character) with their selected form (animation) and calculate the attack based on their level.

image

Now it works fine, but once I create more groups, I will need to have this event 3-4 times or more, based on how many groups exist, plus the events that lead to this.

Instead, if there was a way to declare to the engine that I want to get the info from the following group without selecting it from the editor (The group name is inside the variable), I think it could save me a lot of problems and make life much easier for bigger projects.

Sorry if this sounds confusing, coding isn’t really my main strength (Gdevelop is the only "“coding’” I know, so basically almost 0 knowledge), and I just don’t know if this is possible to do in the engine. Maybe I’m just talking crap.

I’m not sure what you need. Any condition will pick objects that are referenced. You can pick objects by a variable or the animation or multiple variables.

You can put objects in different groups or the same group.

You could use a boolean variable to identify the powers. Say you had archers. IDK if you do. But say you had archers. You could use an object boolean like IsArcher or Canshoot or can anything.

It might be easier to use a variable for specific powers or abilities. Then any character could have the ability.

Instead of say is object an eagle or raven, you could check if the object boolean CanFly was true. Then you could have them all in the same group.

As far as I know, you can use a variable to call an object only if the object is part of a group with this event. But you can’t put a variable in the section where you choose the group to get the object from.

image

Or for other events, let’s get a random action, such as scaling.
If I put my variable SelectedPNG, it simply won’t work cause the editor wants me to select an actual object or a group, but I don’t have the object yet, as the player will select it while playing the game.

image

I know that the above can be achieved with groups and that I can put objects in different groups, and I do use booleans to identify the powers so that I don’t have to edit it for each object.

My problem starts when I have groups that are doing the exact same thing.

This post was mostly made to find a way to handle many objects. Heck I may not even need it in the end. Before your suggestion to include all of the creatures in 1 animation, I was thinking of doing this.

Have 200-500 objects in group PNGS (Keep in mind that the objects already have their own forms/animations etc). The editor may get laggy, I don’t know yet, so to be safe, I don’t want it to read more than 500 objects.

So I create group PNGS2 with 500 more characters, then PNGS3 with 500 more, etc etc

So the player plays the game, they make a team with the creatures.
They select 1 creature that is part of the group PNGS and 2 that are from the group PNGS5

If I try to calculate their total damage, I will have to create the following event for each group that I have.
image

But if I had the option to put a variable in the place of the group name, I could simply change the variable dynamically without having to create the same event again and again just to select a different group.

Yes, the group parameter for the create object by name doesn’t allow you to use an expression.

How do you have 1000+ characters? Are some a variation of another or are they all unique?

It would definitely make life easier if you only had 1 group. Then you would only need 1 set of events.

Is there a constant lag with using a huge group or is it only after adding the objects to the group list?

I would definitely try to slimline it. Maybe you don’t need that many characters or maybe variants can be combined if there are similar characters.

All of them are unique :grin: Well, I don’t have 1000 yet, more like 200.
Most of them are PNGS, which are still images, the rares are animated.

Basically, they are the selling point of my game.

It will be a gacha, character collection game with many modes to play, and I plan to collaborate with different artists, maybe franchises if it gets famous enough etc. I have many plans for it!

Thing is, because it will have so many characters, I want to make the character management as easy and efficient as possible, so that I don’t have to commit surgery on my code when I have issues.

For now, I don’t have any lag, so I will keep adding characters there. The lag happens only once I click Apply on the group window. I found some older posts where users are facing lag once they have many objects in a group, or many images in an animation, so it just scares me a bit.

I really don’t want to change the game engine because of it. I really like Gdevelop.

Do you think it would be possible to allow an expression on the group parameter at some point in the future, or is it impossible with the way that the engine is built?

1 Like

It wouldn’t hurt to add a feature suggestion. I think most parameters should be both a dropdown or expression.

If there is lag than maybe that needs to be optimized.

1 Like