Duplicate and move

how to duplicate a variable object (random card picked) and move it to show in two other locations
right now i have it tweeting to one location, but I would like it to show in another location.


So if I understand correctly, you wish to duplicate a specific object you just created to a new location, seems like a very straightforward solution with just a “position function” . In order to duplicate an object, use action " Create an object at specified position". You will need coordinates of each object you wish to duplicate.

thanks for the response. So my object is a random card from a deck of 52 that has been generated. I would like to duplicate that particular instance (or animation not sure what to call it). In the events if I try to Create object it is always just the #0 Animation of the deck of Cards.


There is a very useful extension, you can check it up Object Stack - GDevelop documentation, there are also examples of premade template projects.

In order for the same duplicate instance to keep its own animation, it needs an instance variable, for example “Animation” , number type cause it will shuffle thought index, I have set it to 4. So if you have 52 same cards created, the ones you want to change the animation you need to define an instance variable.

This example just shows if I have 2 sprites that I have duplicated, they by default begin with 0 animation, so I have created an instance Animation for both of them, and defined the number of animation with index I wished each of them to have.

You can turn the objects into global objects

yes, I think I understand what you are saying , but I don’t think it addresses what I am looking for.

I do have the Stack Object extension installed and used one of the free templates to start my build.

In my game I have a deck of cards that is shuffled randomly and flips one card at a time. Let’s say it is the 4 of hearts, Animation #28 which is Flipped and showing in its location #1.

I would like to make a copy of this card #28 automatically and show it at another location #2 in the scene while it is still showing at location #1.

I can’t do it manually because I have no idea what the card will be. So I need to tell the game to duplicate whatever card is in location #1.

When the next card is flipped the instance in location #1 moves, location #2 is deleted and the next card flipped shows in location #1 and #2…and so on.

Okay so i get what you want.
First create a global variable number named the card’s animation
and then in location 1 put this code.

Then in the location 2 put this event

This will automatically change the animation of cards in location 2 based on the animation in location 1

the deck of cards is a global object

Okay then i think it will still work If it doesnt then add another deck of cards object in location 1 and 2 and then delete the global one

I think this is what I need to do but I can’t seem to get it right. Can you be more specific on how to “location 1 put this code”
“location 2 put this event”
I created a card at location 2 , tried inputting as you said , but the card in location 2 does not change.