Creating Modular PowerUp Systems
<p>I love games with PowerUps! Let’s take a look at a way to create a modular PowerUp system in Unity.</p>
<p>In our example game we’ve created a PowerUp script to handle the behavior for a TripleShot PowerUp. The PowerUp has a chance to drop after an enemy is destroyed, it moseys along in space for 3 seconds before disappearing, and if the player picks up the PowerUp, it gets activated:</p>
<p><img alt="" src="https://miro.medium.com/v2/resize:fit:770/1*GGsZ5zp02hDaRW_8OyedSw.gif" style="height:378px; width:700px" /></p>
<p>If the PowerUp moseys off screen, then it also disappears.</p>
<p>Now I heard that variety is the spice of life, so we gotta have more PowerUps! But what if a game has 100 different PowerUps?</p>
<p>Since the only specific behavior of any PowerUp in this game is to activate the specific PowerUp, and because I’m too lazy to create different scripts for different PowerUps, let’s get modular, man.</p>
<p>We’re going to attach the same PowerUp script to each PowerUp, but we’re going to distinguish the different PowerUps by creating a PowerUp Id variable:</p>
<p><a href="https://medium.com/@stonger44/creating-modular-powerup-systems-37f226137402"><strong>Visit Now</strong></a></p>
<p> </p>