"Create object from it's name" is broken

The action (Among objects “Group”, create object named “name”) specifically states that if the object is not found in the group, nothing will be created. But this is not the case.

The “group” part of the command seems to be completely ignored, and the object is created regardless. Even if it isn’t in a group at all. This applies to any object and any group in the scene.

I just tried it and you’re right!

The object can still be created regardless if it’s included in the group or not. Even if the group is empty, objects will still be created.

which version of gd?..just asking.

Version 5.4.204 in my case.

It always does that, in older versions too.

1 Like

Thx i didn’t knew it,
i was thinking to use that action to keep my tilemaps in order…
then im gonna avoid to use it for now

I don’t think that’s an issue. I’ve used this action many times before without any problem.

I always thought it was intentional, because GDevelop has always been great at making games just work even if I was an idiot and forgot to add the object to the group.

Unfortunately it IS a big problem if you’re trying to use it the way it’s advertised to work. Especially when the basic “Create Object” function is so limited.

I’m sure i can figure out ways around it, but it’ll be an annoying amount of work when there’s literally a function right there saying it does exactly that.

I’m sure they will look into it now. Probably if anyone noticed it before, like me they did not consider it a bug but one of the many ways GDevelop had a habit of making a game work even if you were a beginner and made simple mistakes. So it was probably never reported. I have also seen GDevelop correctly guess which object or animation I meant when I made a minor typo in the name in the event sheet but it was close enough to the actual name and there was no other name like it. For instance Players instead of Player. I did not think to report that either because I assumed it was a nice feature.

Can you expand on how this is a problem? Does it do it’s job of creating an object by name? How are you choosing a name? I’m not saying the action isn’t flawed but I’m curious as to how it’s getting invalid (for your purpose) object names.

The easiest workaround I can think of is to create a structure with a list of the valid objects and then check if the object name that you want to create is a child in the structure.

Alternatively, you could use the equals or contains comparators. If object name contains an underscore.

So i essentially have “Spawners” that need to be able to create a multitude of objects from different groups, using a variable object name, and give them different sub events based on which of those groups the object was in. But as is it just creates each object on each event. Which is… a problem lol.

You’re definitely not wrong, there’s ways around it. It would just be a HUGE hassle since i already have a lot set up around this logic idea, the whole point being making it super easy to design new objects for it to spawn. Instead of having to feed a ton of variables all over the place with every new one.

I think I see what what you mean. It’s a shame there’s not an expression to check if an object is in a particular group. I always wished groups were more fluid and could be manipated at runtime. It would be nice to be able to read the list and add/remove objects from the list.

You can check the number of picked objects for each group. But I don’t know which condition to test first to get a pick list by variable name.

I apologize. This wouldn’t work bc an object of this name might not exist in the scene yet. Maybe if you add the object to the scene first then check the number in the group name and then move it. Not ideal but I’m just thinking out loud
I suggested that the object name expression be made to also function as a condition. Currently, you can use it in compare 2 texts but it doesn’t pick the objects. It only triggers if true.

If object name was a condition

object name equals variable name
Number of objects in group name >0

You could add an object variable that identifies the type or give each object name a codeword like if variable contains or starts with “dragon” or something. Then use this spawner.

You might need a 2nd variable or a structure with the object name and the spawner to use based on the object.

I wish I had a firmer solution. Something more dynamic.