How to "copy" an element (sprite) to a global variable?

The title is saying about my question. I’m have a multiplayer game with changing characters before game start.

Character change scene

  1. user click on a character
  2. character’s name is set to a global variable (to able using character’s name in other scenes)
  3. once all players is set the character, both clients have a global var with characters name and both clients change scene on gameplay

Now, the question:
how to move the character what user set?

example:

You cannot do that. I’ll try to reply, but I might be offtrack, because that depends on how you set up your characters.
You should set the chosen name as an instance variable of PlayerObject, and in the conditions side of your screenshot, check the value of PlayerObject.Variable(characterName)).
Then the actions will apply to the right PlayerObject.

I have multiple characters, I’m must create a instance variable on all characters?

Not necessarily, if you have only one instance for each character object you can also just use the object name.

To do so, first create an object group with all your characters in it. When clicking in a character, make sure you store the object name with the Object.ObjectName() expression.

The normal process to pick the object to apply actions on is object picking, where you use an object condition to filter out objects you do not want. Here, you would use an “Object name” condition to check whether or not the objects match the one in your variable. GDevelop would automatically filter out objects that do not match the name check, and your action would only apply to the object you want to apply the actions on. This condition doesn’t exist though :sweat_smile: Therefore, you need to use a non-object condition, that doesn’t do any filtering for you, and do the filtering yourself with a for each event.

This is pretty easy: just put a condition to compare the object name with the scene variable in a for each event. It will execute for each instance of your object group, so it will check the name of each objects one by one independently, allowing you to only run subevents on objects whose name match.

All this complicated explanation to say basically this:

If you want to check out the project file: CharacterSelectionByObjectName.json