Switch Statements to the Rescue!

--

Objective: We need to be able to change functionality between our powerups.

Using switch statements are far more effective than a ton of if else statements when you have, say, 50 powerups you want to control.

our current setup for our powerups — if else statements.

A switch statement lets us switch through a variable and in our case the variable is going to be the powerupID.

We implemented the switch statement and it runs the exact same as the if else would, but much cleaner and way more organized.

--

--

Chelsea Cruise
Chelsea Cruise

Written by Chelsea Cruise

Unity Developer, Software Engineer, Game Designer, Graphic Artist

No responses yet