Talk:Treasure Chest/@comment-66.191.216.12-20140619203709/@comment-24475768-20140620170554

There are several ways to do it. Let's say you want 10 coins.

You could create them all at once, by having instead of the "once" line:

WHEN [once] DO

> WHEN [for each of] [10] DO [object set var: treasure] [increment by] [create] [gallery picker -> coin] [at position] [position]

and changing the move line (6th one) to: WHEN [for each of] [object set var: treasure] DO [it] [move] {keep the same modifiers}.

Now, that means the coins will be spawned at the same position, and you probably won't be able to distinguish between them. But you could add some randomness to solve that problem: after [at position], put [position] [plus] [random vector].

Another way to do it is to spawn the coins one at a time. You have to make sure you spawn all coins before the chest gets destroyed. To do that, don't put anything else than [play fx] [Energy Burst B] inside the [once], and put that line to create the coins:

WHEN [object set var: treasure] [count] [less than] [10] DO

> WHEN [countdown timer] [0.1] [loop] [trigger on start] DO [object set var: treasure] [increment by] [create] [gallery picker: coin] [at position] [position]

I hope that helps.