I have an FSM set up to create clones of a die based on how many you 'own', and it rolls them all in tandem when the roll button is pressed and creates clones which are stored in a global 'Game Object' variable.
I can create the correct number of dice through a loop, no problem. However, I want to destroy all clones when the roll button is pressed again. The problem is that whenever I click the roll button again, the 'Destroy Object' action only destroys the first one created in the loop-- meaning that if I spawn in 3 dice, only 1 is being destroyed and the rest are left on the board, creating an exponential number of dice. Despite the object (D4(Clone)) being correctly stored global variable, and all of the clones having the exact same name, it doesn't destroy them all (even if I add another loop onto the destroy state).
My FSM is set up as follows:
State 1: Destroy Object (Game Object: spawnedDice)
State 2: Create Object (D4, Store Object: spawnedDice)
Loop State (Loops: diceQuantity(2), Finish Event: FINISHED)
Any help would be appreciated!