Upgrade System Design and Implementation

March 5, 2025
Tools: Unity

Introduction

In the second half of development for Poly-Vinyl Pests! our team wanted to add in an upgrade system for the players to progressively get stronger throughout the game. The beginning of this development cycle included the introduction of 6 new developers on our team with two of them being designers. Our team, being composed of 15 developers, decided to split the team into two scrum teams one for boss fights and one for upgrades. I was the lead for the upgrades team so I helped our scrum team’s producer manage 4 designers and 2 artists to implement the base upgrade system.

Design

The first thing I wanted to do was get the designers together and brainstorm how we wanted this system to work. In the beginning we knew that we wanted to keep all the code for our upgrades self contained, so having a base upgrade that all the other ones could inherit its attributes from would be the right approach. Below is the goals we created for our initial upgrade system in a sprint planning meeting.

a

In the end I decided on creating a base upgrade class with multiple functions that would be called in the player script in different situations. This design helped the less technical designers program self contained upgrades that wouldn’t break the player controller if there was a small bug.

Implementation

I was in charge of rapidly prototyping the upgrade system in a week. The main goal for the initial implementation was to get an upgrade that gives your player stats and an upgrade that has a passive effect. The implementation involves the base class, so I got to work implementing that. This is what I created, each function was called in the player script

a

With this image there is the “OnShoot” function which will be called each time the player shoots. Similar functions are in the base upgrade abstract class and will be called in the player script instead of the upgrade script itself.

Some of the upgrades may need a reference to something, usually the player its being attached to, at least once. To implement this I created a “InitUpgrade” function that is called when the upgrade is instantiated in the scene and placed on the player. This function will get references to anything it needs to and is where you can add stats to the player. In this example below is getting a reference to the player and giving them stats.

a

To make an upgrade in engine you would just need to make a new script inherit from the base upgrade class and put it on a game object, then you could just drag it into the assets folder to make it a prefab. The upgrade system uses prefabs as the upgrades and applies the script itself onto the player when they pick an upgrade. I made values of the base upgrade script serialized field so that designers could easily create a new script that inherited from base upgrade and start working immediately. This is an example of an upgrade prefab with its values filled out:

a

Contact Me

jeffreypopek@gmail.com