Unity Game Development — Optimizing Code with Switch Statements

Previously, I worked on a script to create modular power-ups. The code uses conditional statements to control which type of power-up the player collects. If we decide to add more and more types of player upgrades, this code will get long and messy.

Enter the switch() statement.

The switch statement is a selection statement that…

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Key Points to Consider When Planning a New Intranet for Your Business

Why You Should Use Git For Personal Projects

My GSoC ’21 Journey: Week 8

Convert MP3 to AAC in Java

Start Programming Quantum Computers With Only 2 Lines of Code.

How to insert an image into a Word DOCX document in C# .NET Framework

BLoC for flutter -Part 1

Celebrating Our Community: How Calia & Laurel became coders

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Claudio Grassi

Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.

More from Medium

RxJS: map vs pluck vs mapTo Operator

Unity camera plugin save image data as bytes

Breaking out of virtual chains with Slay

Add Math Equations to PowerPoint in Java