Having issues repeat code

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

So this is a simple game, There is a pile of socks, you are presented another sock with a patern, you find teh sock and click on it and if it matches, the pile resets… Well it should

All the socks on the back layer reset with no isses

the socks on the Top layer do not

what it should do, is shuffle an array with 20 numbers in it,
then if should loop through every sock on the top layer, and change its animation to the frame number of the variable, and +1 to the variable, so it loops through the array

The issue is it does not change the anmation and i cant figure out wy

.

What is the expected result

if socksChanged is false it should then change the animation of the socks, the animation doesnt change, everything else is working perfectly fine its just the animation.

What is the actual result

everything on back resets and id of 500 resets but nothing on top resets and changes animation.

Related screenshots

The way it works (I think) is when GDevelop creates objects, it puts them in its own list. First in the list is the first object created, second in the list is the second object and so on.

When you Repeat for each object, it goes through its internal list. Setting the animation is done to each object in the same sequence every time, and it never changes.

If the array numberList is a randomised order of the number of Socks objects, then you can to use “Change the number of the animation of Socks set to numberList[pickCount]”.

1 Like

Small sidenote, you don’t need more than one Shuffle action. It is the same level of randomness whether you do it once or 1000 times.