6 Creating a basic 2D platformer
This chapter covers
- Moving sprites around continuously
- Playing sprite-sheet animation
- 2D physics (collision, gravity)
- Camera control for side-scrolling games
Let’s create a new game and continue learning about Unity’s 2D functionality. Chapter 5 covered the fundamental concepts, so this chapter will build on those to create a more elaborate game. Specifically, you are going to build the core functionality of a 2D platform game. Also called a platformer, it’s a common type of 2D action game, best known for classics like Super Mario Brothers: a character viewed from the side runs and jumps on platforms, and the view scrolls around to follow. Figure 6.1 shows what the end result will be.
Figure 6.1 The final product of this chapter
This project will teach concepts like moving the player left and right, playing the sprite’s animation, and adding the ability to jump. We’ll also go over several special features common in platform games, like one-way floors and moving platforms. Going from this shell to a full game mostly means repeating those concepts over and over.