2D Flappy Bird Clone Game Tutorial – Unity3D (C#)

2D Flappy Bird Clone Game Tutorial – Unity3D (C#)


Play Demo

I guess you’ve played this funny game. It’s the most downloaded mobile game in January, 2014. Is it hart to implement? The answer is no. Most probably, it’s the easiest and quickest game to implement ever. You just need to touch on screen to make the bird jump and avoid the obstacles. That’s all!

We will change the touch action with assigning a key. Lets begin.

At first, create a 2D project in Unity. You can find the sprite sheet on Google for the visual objects. Create a basic animation for the bird. To do it, download the sprite sheet from Google and add it as a new asset to your project. Choose “Multiple” as sprite mode and open the sprite editor. In editor, rename the objects that will be used in your scene(birds, ground and obstacles).

Screen Shot 2015-07-09 at 15.16.32

Apply the changes and close the editor. Now, your sprite sheet is divided to multiple images. Select bird1, bird2 and bird3 and drag them in scene.

Screen Shot 2015-07-09 at 15.19.15

Save the animation. Also, add the ground, obstacles and change the color of camera background. When you press play, you see the scene with an animated bird.

Now, we need to add some physics. Add Collider2D (circle for the bird and box for the others) to all objects and add Rigidbody2D (select fixed angle) to the bird.

That’s how my scene looks like.

Screen Shot 2015-07-09 at 15.24.54

Create a C# script named BirdAction. We will add a horizontal speed to the bird and make it jump when you press the space key.

Speed means movement speed and jump means jumping force. You can change gravity, mass, speed and jump variables to get the best performance for your game. Also, you can change the dividing values in start and update functions.

Lets create a simple following script for camera.

We want to make camera to follow only horizontal direction. So, just take the x position of the bird. That’s all! Enjoy it.

You can download the source code here.

©Coffee Break Codes – 2D Flappy Bird Game Tutorial – Unity3D (C#)

Leave a comment

Your email address will not be published. Required fields are marked *

8 thoughts on “2D Flappy Bird Clone Game Tutorial – Unity3D (C#)