(Ep 8) How to Add a Prestige System! - Unity C# Idle Game Tutorial Series [2021 Edition]
Watch on YouTubeVideo summary
In this episode of the Unity idle game tutorial series, the creator demonstrates how to implement a prestige system that allows players to reset their progress in exchange for a special currency called golden flasks. The development process begins with creating a new script named PrestigeManager, which handles all user interface components including text displays for current currency and a confirmation dialog box. When triggered by clicking a button, the system presents a prompt asking if the player wants to proceed, offering both yes and no options to manage the reset action safely without accidental data loss.
The core functionality involves calculating prestige gains using a mathematical equation that converts accumulated resources into new currency based on current progress levels. Before resetting any game state or clearing upgrades, the script first calculates how many golden flasks should be awarded by applying this formula to the existing flask count and adding it to the player's total. Once the reward is secured, the system resets upgrade counts and clears previous data while simultaneously updating the user interface to reflect these changes, ensuring that players immediately see their new currency balance after performing a prestige action.
To make the gained golden flasks useful in gameplay, the tutorial introduces an effect multiplier that increases production rates per second based on the amount of currency held. This is achieved by dividing the total flask count by a specific number and adding one to ensure the boost starts at zero if no flasks are present; this value then multiplies all existing upgrade effects dynamically. The creator also addresses potential discrepancies in displayed numbers caused by floating-point precision issues, suggesting the use of formatting extensions like "N0" to display clean integers rather than long decimal strings that can confuse players during gameplay updates.
The video concludes with a preview of future content where different mathematical curves for prestige calculations will be compared and explained in detail, allowing developers to choose formulas best suited for their specific game mechanics. Throughout the process, emphasis is placed on organizing UI elements within dedicated objects like popups to maintain code cleanliness and ensuring that all necessary references are correctly linked between scripts such as the controller and upgrades manager. By following these steps, creators can integrate a robust prestige system that rewards long-term play while providing meaningful progression boosts for their idle games.
Read the full video transcript
hi everyone it's cryptograms here and
welcome back to another unity idol game
tutorial video
this is episode 8
and today we'll be working on the
prestige system so i have a button in
the bottom left corner
this will be our prestige button
and our prestige currency will be golden
flask for example and this is our text
to display how many golden flats we have
at the moment and when we click this
press each button we'll have a
confirmation
asking us if we want to
prestige
we have a yes and a no button so we'll
get this all going by the end of this
video first i'm going to create a new
script
so we'll just create an empty and this
will be called our prestige
and the script itself would be called
the prestige manager
i'm going to add all of the ui
components to this class
alright so it's pretty simple just two
texts
and a game object representing the
confirmation
so these four methods are the ones we're
going to be using today so the first one
will be the prestige gains so our
prestige equation we'll go right in here
we'll update some ui related stuff
and
toggle our confirmation and do the
actual prestige
i also want to quickly mention if you
don't know what a prestige system is
it's basically a way to reset your
progress in exchange for a special
currency that will make your game
progress faster alright so starting with
the first one i will talk more about the
math in a separate video but i'm just
going to throw a random
curved equation
into this method so let's just do square
root
um of our
flask and divide this by some number
like a thousand so
and that's just our equation it's very
basic yeah we'll go over the different
types of curves you'll be using in
different ways to adjust this equation
and that kind of fits your game
but
when we do that
there is really no progression style in
this tutorial example so far so that all
depends on what kind of upgrades you add
and how many upgrades you have as well
so the prestige equation for idle
research is going to be completely
different
than
our kind of style here
so i'm just going to convert that to an
expression body since it's just a
one-liner
all right so we have our prestige gains
and inside of the update we'll just
update our text so and the currency text
will be very similar except we need to
add a new variable called golden flask
in your data class so let's add that
real quick and set that to zero in the
constructor i'm going to
add using static controller at the top
so we can kind of simplify this a bit
for toggle prestige confirm it's
literally going to be prestige confirm
now for the toggle prestige confirm it's
literally going to be
prestige confirm dot set active
explanation mark
prestige confirmation dot active self
expression body
and now for the pressed each
so this is where we need to reset
everything and get our
golden flask so
first we'll start with that and first we
want to add our golden flask before we
actually reset anything because this
prestige gains is based on our current
flask so we'll just do the addition
first
so we'll add our gains to our current
golden flask and then we'll start doing
the resetting process which in our case
it's pretty much just resetting our
upgrades
and our flash so
all right so
don't forget to add system.link at the
top because we are creating
our new array and converting it to lists
and we're just resetting all of our
upgrades and our flash and we also want
to update the upgrade ui as well
and we do that right here so it's a very
short script but this is all we need to
do so first we need to drag our
currency text and our gains text
and drag our confirmation
into here also i created a popups empty
game object here which just stretches
the entire screen
and i'm going to keep all of my pop-ups
in here just to keep it a little
organized and in here we need to set no
to we need to first drag our prestige
um object into the on click and for no
it's just going to toggle the prestige
confirm and yes we'll do the actual
prestige
and close that
have the prestige confirm
toggle method
and also if we were to prestige this
menu won't go away so we need to toggle
our prestige confirm at the very end as
well all right so as you can see based
on our
flask right now we can get 916 golden
flask right now if you were to press
each
everything would be gone but these don't
do anything at all
so
if we were to get an upgrade for
production
you would see that it just doesn't do
anything let's say we want our golden
flask to effect on how many flasks we
get per second so what we can do
is create a new method called
our prestige effect and this will
essentially multiply our flash per
second gain
and we're pretty much done with that
now what is this equation going to be
i'm just going to keep it simple and
just divide
how many golden flasks we have by a
hundred and we want to add one because
the prestige
boost will initially start at zero if we
didn't have the plus one and that will
just make everything zero okay so we
want to use this prestige effect method
inside of our
upgrades manager
so in order to access it we need to
create a singleton and inside of the
awake method which i made private we
will set our prestige manager equal to
this instance now let's head to our
controller script and i might have said
upgrades manager but i'm going to say
controller but basically we have our
flash per second
and all we need to do is just multiply
our total by our prestige manager dot
prestige manager dot prestige effect so
we're getting more flash per second now
so let's just buy a bunch of upgrades
and just
keep going so you may notice that our
productions here
aren't exactly accurate if we were to
buy one of these we don't get plus one
more per second we get around 10 more
per second so let's fix that so this
will be done inside of our upgrades
manager and you can see it's based on a
string array
so
we're going to need to change how this
works so inside of the update method
we're constantly
updating our production ui so before we
update the productions ui
we're going to have to change the
upgrade names array so in order to do
that
i'm going to allow us to do string
interpolation
and basically multiply our base values
by our prestige effect and this does
look a bit um repetitive and kind of
silly but if you want to change how the
naming system works that is up to you
all right so let's save and go back
and see if our labels have been changed
all right so now it looks like this
which means it does indeed work so if we
were to prestige these numbers should
update yep
however they look ugly so i'm going to
call the note extension method so now it
looks like this
and i think that's good and that is the
end of this video if you enjoyed and
thought this video was helpful please
leave a like and comment your favorite
video game in the comment section below
if you want to support me and the
channel check out the patreon in the
description below or you can hit that
thanks button which should be right next
to the like button anyways i will see
you all in episode 8.1 which will be
the math explanation between different
prestige curves so i'll be comparing
different ones and
you'll be able to choose which one's
best for your game i'll see you all in
the next video
peace
[Music]
maryland