Scrolling space shooter - making enemies drop currency

Hello! I’m currently working on a top-down scrolling space shooter, using the Space Shooter Unity tutorial series as a basis. I’ve got various enemy and weapon types and a way to spawn enemy waves, but the next thing on my list is for enemies to drop several small scraps of metal (which will be used as currency for upgrades) when they die. I really love the feel of Bloons Super Monkey 2, and would like this aspect of the gameplay to evoke that. If you’ve never played BSM before, here’s a screenshot:

BSM2 Screenshot

The small red circles are currency that popped bloons will drop that the player can pick up - each bloon drops several red orbs (probably somewhere around 5-10), which fall towards the bottom of the screen and are sucked up by the player when they get within a certain radius.

Is this best accomplished by having each piece of currency as its own GameObject, and instantiating them in a clump with some kind of artificial gravity that causes them to fall towards the player? Or is there a more efficient way to accomplish this?


Hi egan

Making each one its own GameObject is a perfectly valid way to start. If it turns out too slow then you’ll need to optimize it!

Probably the big cost will be instantiating lots of coins. The general solution to this is pooling, in which you instantiate a load of bits of currency up front (when the game starts) and disable them all. Then when you need one, you simply position/enable it. Rather than destroying them, you disable and return to the pool.

There’s a lot of tutorials on pooling, but I found this one Unity wrote themselves so might be worth a look: Object Pooling - Unity Learn