2D Platform Game
Total Page:16
File Type:pdf, Size:1020Kb
Sourav Basu 2D PLATFORM GAME Developed using Unity game engine Thesis CENTRIA UNIVERSITY OF APPLIED SCIENCES Degree Programme in Information Technology December 2017 ABSTRACT Centria University Date Author of Applied Sciences December 2017 Sourav Basu Degree programme Information Technology Name of thesis 2D PLATFORM GAME. Developed using Unity game engine Instructor Pages Kauko Kolehmainen 54 + 44 appendices Supervisor Kauko Kolehmainen The aims of this thesis were to create a game in 2D using the Unity game engine, and to learn about the new development tools introduced throughout each update and Unity versions. Unity is a cross- platform game engine, therefore releasing the same project on different platforms is quite easy. With smartphones and handheld devices increasing in popularity, 2D games have attracted a lot of atten- tion. Moreover, with updates over the past years, Unity has seen many changes in 2D development with the addition of new tools and mechanics, making game development much faster. The game developed for this thesis is a platformer game. This means that the character in the game has to try to avoid traps, enemies and falling into death and must try to reach the finish line at the end of each stage. There is a health system in the game for the player and enemies, so that they are at- tacked few times before getting killed. There is a point system, which the player is required to fulfill in order to end the stage. This game consists of three different stages, the third being the boss stage where a stronger enemy spawns. Killing the boss is the main objective of the game. Even though the game has only three stages, it is possible to create more stages in between, using saved assets in the projects assets folder, and this will be further explained along with other topics later into the thesis. The game created as a result of this thesis is a good example of a modern-day 2D game. It is possible to use this as a step-by-step tutorial for creating a game. Keywords: 2D, Unity engine. CONTENTS 1 INTRODUCTION ........................................................................................................................... 1 2 OVERVIEW .................................................................................................................................... 2 2.1 History ....................................................................................................................................... 2 2.2 Asset Store ................................................................................................................................. 3 2.3 Licenses ...................................................................................................................................... 3 2.4 Unity Interface ........................................................................................................................... 4 3 GAME DEVELOPMENT .............................................................................................................. 6 3.1 Planning and requirements ....................................................................................................... 6 3.2 Scripting ..................................................................................................................................... 7 3.3 Unity 2D features ....................................................................................................................... 8 3.3.1 Sprites ............................................................................................................................... 8 3.3.2 Physics 2D ...................................................................................................................... 12 4 IMPLEMENTATION PROCESS OF THE GAME .................................................................... 15 4.1 Creating New Project .............................................................................................................. 15 4.2 Basic Structure ........................................................................................................................ 15 4.3 Player ....................................................................................................................................... 16 4.3.1 Player Physics ................................................................................................................ 16 4.3.2 Movements ..................................................................................................................... 17 4.3.3 Attack System ................................................................................................................ 21 4.3.4 Player Animations.......................................................................................................... 25 4.3.5 Player Health And Energy System ................................................................................ 29 4.4 Non-Playable Characters ........................................................................................................ 34 4.4.1 Movements and Animations .......................................................................................... 34 4.4.2 Attack and Health System ............................................................................................. 39 4.5 UI Canvas ................................................................................................................................ 45 4.6 Level Design ............................................................................................................................. 50 4.6.1 Loading New Scenes ...................................................................................................... 51 4.6.2 Audio .............................................................................................................................. 52 4.6.3 Checkpoints and Exit signs ............................................................................................ 53 4.7 Building the Game ................................................................................................................... 55 5 CONCLUSION ............................................................................................................................. 56 REFERENCES................................................................................................................................. 57 APPENDICES Game Scripts 1 1 INTRODUCTION The project is a platformer genre game, where the aim is to reach endpoint through obstacles and ene- mies in each stage. It was made using Unity 2D and it is a Windows Operating System game. Unity was chosen to develop the gamewas, that it is becoming more and more famous in producing some amazing games.A free version was used to make this game, and even though not all the features are available in this version, the tools provided were more than enough to develop a simple 2D game. Uni- ty is an ultimate game-developing platform where it is possible to release the same project on multiple and various platforms, such as Linux, Mac, Android, iOS, Xbox, PlayStation and more. Even though 3D games are more attractive and visually more realistic, 2D games are also very popular as well, especially with smartphones and tablets gaining popularity each year increasingly. With that in mind, Unity developers decided to release 2D features in 2013 with completely new 2D features and toolsets. With these additions, developing 2D games is much easier now, compared to earlier. In this thesis, I will take a closer look at the new features of Unity 2D and explain how a game can be developed even with a basic knowledge about programming and Unity game engine. While working on the game, I was able to acquire a deep understanding of C# language. Although there were some Unity syntaxes that were new, but it was not hard to comprehend them. The purpose is to show the advantages of using Unity and to learn about the latest 2D features that have been updated over the past years, since 2D was introduced. The game that was developed was solely for study purposes and is used as an example in this thesis. This thesis can also be used as a tutorial to create a basic 2D game from start to finish. Certain terms used in this thesis will be exactly the same as in Unity's documentation, for example GameObject and Rigidbody. Scripts for the game can be found in the Appendices. 2 2 OVERVIEW Unity is a multiplatform game engine that supports 2D and 3D graphics.Games were commonly scripted in C# and UnityScript, similar to JavaScript, which makes them much easier to understand. Currently, Unity 2017.2 is the most updated version and at the time of Unity 5 and Unity 2017.1 re- lease, Boo and UnityScript were removed from scripting languages, respectively. Unity version 5.5.1 was used to develop the game for thesis. (Alexsadr 2014.) 2.1 History Unity is a cross-platform game engine that was developed by Unity Technologies. Unity Technologies was founded by David Helgason, Nicholas Francis and Joachim Ante in 2004. Many global companies helped Unity Technologies by funding the project, in hopes of developing an engine everyone could afford.The Unity engine was developed using C and C++ programming languages. For scripting and coding,C# and Java languages are used. (Corazza 2013.) In 2005, at Apple’s Worldwide Developers Conference, the first version of Unity was released. At the time of release, Unity 1 could only build projects for Mac systems. With successful