Edit: I don’t understand the need to swap the objects. How are you adding objects? And I know you said when coins are collected, objects get swapped, which objects and under what premise? Do you just 1 random or several. Are they player objects or background AI characters or objects?
OK. The technique for swapping an object would be similar. Under [other actions] [object] is [create an object from its name] . You use the group name, an object name from the array and the x, y would be the current objects x, y. So, it’s among group name create object object name at x, y
You can use this to spawn random objects or swap existing.
Im not at my pc but later I could throw together an example if needed.
Create an array with all of the object names in the group. Or name the objects something like Obj1, Obj2, Obj3
At the start and when the coins are collected pick a random object, add a new object at it’s position and then delete the old object.
Remove the new object from the array and if you want the old one used again then read it to the array. Or just add the new object and delete the old if you go by object names without the array.
https://wiki.gdevelop.io/gdevelop5/all-features/object/reference/#actions
If there are multiple objects of each object type then you wouldn’t need to remove or add the object name to the array.
You could either use the name from the array or name the objects all the same with a number after them like Obj1, Obj2, Obj3 then add an object using the name “Obj” + ToString(RandomInRange (1,number of objects in group - 1)
Whether you put the names in array or name them all the same with a sequential number depends on what they represent and how you interact with them. An object named fox would be easier to write events fir than Obj1 unless you put all of the objects in a group and write actions based in the group name. Then it wouldn’t matter what the object names were.
It also depends on how much randomness you want. Do you want true randomness which might lead to a lot of one object at tunes or a but of controlled randomness where there’s a bit of balance.