A starter kit (including detailed tutorials and source code) on creating your own 2D Unity Beat 'Em Up game, like Double Dragon.
What could possibly be a more amusing way to burn time than slaughtering a horde of bad guys with trusty right and left hooks? Creating your very own beat ‘em up game, of course!
Beat ‘em up games have been around since the inception of 8-bit games and experienced their glory days when early console gaming and arcade gaming were all the rage — long before the world turned to pixels in the early part of the 21st century.
In the Unity version of this popular book, we’ll walk you through building a complete beat ’em up game on Unity.
With Unity’s great suite of 2D tools, it’s easy to build a game once and make it available to multiple platforms. The dark days of building for one platform, then painstakingly building your ingenious game on another engine for a different platform are over!
More than a book, this starter kit equips you with the tools, assets, fresh starter projects for each chapter, and step-by-step instructions to create an addictive beat ‘em up game for Android and iOS.
Each chapter builds on the last. You build out features one at a time, allowing you to learn at a steady, logical, and fun pace. Components were designed with reusability in mind so you can easily customize the resulting game.
This starter kit is for beginner to intermediate developers who have at least poked around Unity, perhaps even built a game, but need guidance around how to create a beat ‘em up game.
You’ll take a crash course on Unity and get started with creating your Unity Project and main menu scene. While creating the main menu for the game, you’ll get your first taste of Unity and its interface. You’ll also create a button and script that navigate to your second scene: the game scene.
This chapter is all about tile maps: smaller repeating sets of sprites to form up, a bigger, more elaborate picture. With this, you’ll create the retro background sprites for your game. You’ll also learn how sprites are drawn in the scene and you’ll understand a key feature of Unity: prefabs! These allow you to save GameObjects, allowing you to create objects on demand.
This chapter is all about setting up the game scene: implementing cool techniques that allows you to create a “2.5 dimensional” game with the engine. Being the cunning developer that you are, you’ll accomplish this by rotating all assets in the game, including the Pompadoured Hero, the protagonist of the game! You’ll learn how to process user input, animate a 2D character and create bounds to keep objects, especially the hero, within view. With the help of the keyboard inputs, you’ll create a hero with stunning hair.
This chapter creates new actions for the hero, empowering him to be a genuine, bot-crushing warrior. You’ll begin by simulating a directional double-tap gesture to make the hero run. Building on your virtual control scheme, you’ll create and add two custom buttons to make the hero perform other actions, such as jabbing. Then you’ll enhance the 3D feel of the game with shadows and jumping. Aside from new actions, you’ll also learn an important process: refactoring! You’ll re-organize the hero script, resulting in cleaner code that is easier to reuse and understand.
In this chapter, you’ll spawn an enemy robot for the hero to fight. You’ll give each rust-bucket a special animation that will play when hit, and a life counter that will knock out the robot. You’ll also work with the layering of physics objects and collision handling, which will let the hero beat up some helpless robots until they die. Poor, poor robots.
It’s the revenge of the fallen! In this chapter, you’ll develop artificial intelligence for the robots, implementing a system of weighted decisions that will determine each robot’s action. This time, the robots won’t stand idly by while the hero pummels them—they will aggressively fight back.
You’ll enable your game to handle battle events: a situation requiring the hero to fight enemies until no enemy is left standing! You’ll also control and define enemy spawns using ScriptableObjects, creating levels for the game. Additionally, you’ll enhance the game, and the hero’s ego, by adding entrance and exit animations whenever a level starts or ends.
Naturally, you’ll want to trick out your hero with flashy moves. In this chapter, you’ll dig deep and learn to extend the current actions system by giving the hero the ability to do a chained attack with a 1-2-3 punch. You’ll also give him combination actions, such as a jump punch and a running kick. At this point, the game will need a few swipes of polish, so you’ll fix a few bugs and add a hit effect for everything that punches in the game. Additionally, you'll add logic so the hero gets knocked out when he takes too much damage!
You’ll begin the chapter by creating a heads-up display (HUD) to keep the player informed of critical stats, such as hit points and when to move forward on the tile map. Then, you’ll further polish the game with floating damage numbers and explosive hit animations for each attack. Lastly, you’ll add on-screen controls to enable the game for mobile devices: a directional pad (d-pad), as well as attack and jump buttons.
Boss characters are essential. Bigger, badder and more barbaric than the other antagonists, they are a hero’s most formidable enemy. In this case, the boss will be an ape-like monster with a high-top fade. You do not want to get in its way! To give the hero a fighting chance, you’ll also add a powerup to the game: the Punch-a-tron Operational Work-gloves 300, or P0W 300. This glorious pair of mitts allow the hero to punch harder, giving him extra “oomph” when fighting the boss. You’ll also create trash bin containers; when punched, they drop these mighty gloves!
It’s the homestretch! In this chapter, you’ll add the final piece: audio. You’ll add a catchy background theme song, along with hit effects and death sounds for all actors in the game. To get the game ready for release, you’ll fix bugs as well. By the end of this chapter, you’ll have a complete and polished beat ‘em up game!
The game will be done at this point, but one final task remains! In this chapter, you’ll run PompaDroid on a mobile device! You’ll add platform-specific controls for Android, and create builds for Android and iOS to show to your friends.