Book Image

Unity Game Development Scripting

By : Kyle D'Aoust
Book Image

Unity Game Development Scripting

By: Kyle D'Aoust

Overview of this book

Table of Contents (17 chapters)
Unity Game Development Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Achievement trackers


In this part of the chapter, we will add trackers for each of our achievements. Each tracker will have its own function. The functions will be very similar to each other, but will have their own variables to affect.

When the functions are called, it'll take in an integer; this integer is the amount of the stat that we want to check. Within the function, we check with our bool variables to see whether that achievement can still be gained. Next, we check the amount in order to iterate the achievement level appropriately.

Once the achievement level is at its highest amount, we disable the ability to gain more achievements for that skill.

Tracking the kills

Our first tracker will track the player kills; let's add the tracker function now:

void Kills(int Amount)
{
  if(getKills)
  {
    if(Amount >= 10 && Amount < 49)
    {
      if(achKills != 1)
        achKills++;
    }
    if(Amount >= 50 && Amount < 99)
    {
      if(achKills != 2)
        achKills...