How to pick an object whose name is decided by variable?

I’m creating an object called by a VariableString, but then I need to change a variable of this dynamic object, and unfortunately, the “object name” field does not accept the expression “VariableString(GuyOfTheDay)”, and I can understand why, because the object names are just references.

I researched here and didn’t find much about it, maybe there really isn’t a solution, but it’s strange that the engine allows creating an object for the variable, but not being able to edit its properties afterwards, so I think it’s worth the question.

Can anyone think of a way to resolve this by other means? I’m trying to do something for here…

Can you post a screenshot of the code used to create the object and attempt to pick it?

1 Like

1 - Calling the sequence of events
2 - Looping that defines which value of the object variable will be registered.
3 - What really matters - The code that calls the object, here I am editing it directly “en1_1” but I would need to edit the "VaribleString(vEnemyOfMoment) in fact.
4 - The Trick I just invented to try to solve the problem, creating an invisible object in the same random location as the dynamic object (called by variable).
5 - Picking by collision with the invisible object, it worked, but I’m afraid it’s not a very scalable method and that can generate incorrect picking when there are many enemies on the screen.

When you create an object it becomes picked. You just need to reference it with the group name instead of an object name. The variable no longer matters.

Edit: note the object only remains picked during the event and subevents. Afterwards you can pick through the normal ways like collisions or variables using either the group name or object name. Also, sometimes events need to be placed on separate event lines. It’s a timing thing. Occasionally, things don’t happen until after an event line.

1 Like

The idea that when selecting a group, I’m actually just selecting an object, is counter-intuitive, and this was my big mistake haha worse that I was still questioning myself, why did I need to choose a group to create an object per variable… ADHD rules! :sweat_smile:

Thank you!

About edit: from the moment I manage to register an “ID” in the object, I think I won’t have problems with events in other blocks. As a last resort, I reuse the idea of collision with an invisible object with simultaneous spawn.

1 Like