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

The achievement system


Achievements are being used now in just about every game out there. You can see them across all genres and gaming platforms, achievements are everywhere. They give the player a sense of pride and accomplishment, knowing that they did something so much that they get rewarded for it. Achievements are also a way for players to brag and show off what they've done in their game.

Prototyping the achievements

Similar to how we prototyped our stats, we will need to prototype the achievements. The stats will be used to unlock achievements, but not every stat will have an achievement for it. For this reason, we will have fewer achievements than stats, but we will have different levels for each achievement.

Here's a list of the achievements that we will track:

  • Kills

  • Total gold

  • Gold spent

  • Level

  • Rounds won

  • Time played

Adding the required achievement variables

To get things started, create a new C# script and name it AchievementSystem. Next, let's create our variables:

int achKills, achTotGold...