For full android game click on the link below :
Download Full Game
First of all open Unity and Navigate to new project give it a name say Flappy bird clone and Select 2D in the bottom left corner.
now you will have this screen,
1-click on main camera and select the background color for your game as shown in picture below.
2-Now You will create the world i.e limits of screen so that your character can never go out of your sight.
for doing this you have to add ground on both sides of main camera.
so download these pictures and navigate to the assets folder in your project folder and make a new folder rename it as sprites and copy-paste these photos in it.
ground |
obstacle |
now you will see the sprites folder in the right corner of unity just drag the ground and drop it in the scene of your game 2 times in such a way that it covers the bottom and top like the picture shown below.
click on add component and search for rigid body 2d And Add it , now search for box Collider 2D and Add this too.
4- Now if we will click on play you will observe that both grounds will fall down due to gravity. So here we will check the IS KINEMATIC box
Now they will remain intact in their positions even after clicking the play button.
5-Now click on layer and goto add layer :
Add a layer named Weired Physics in it.
Now click again on both grounds one by one and select weired physics in layers section:
6-Now we will add Character in it, You can add any character even your own photo cropped in a circular pattern in adobe photoshop with transparent background.
But in here we will add a bird sprite that is given below download it and save it in the sprites folder in your project folder:
Character |
7-Click on bird and set the import properties :
set the settings as shown,
uncheck generate mip maps and click on sprite editor :
Select Type as grid and use Pixel Size X=150 and Y=150 then click slice.
Then click on apply and you will have four equal sized sprites of your character
8- Now Right click in project and create a Prefab:
Now Drag any bird sprite into Scene :
(we are doing all this prefab thing to get a real flying bird animation. If you don't want animation you can skip all this by just adding any one bird sprite and go to step 9)
And Drag back that bird from hierarchy to the prefab in project :
now delete it from hierarchy and drag the newly created prefab into hierarchy :
now select all bird sprites and drag it into prefab in hierarchy
Now Click on play You will see a bird flapping its wings.
9-Now right click in project panel and create a C# script rename it as bird
=> now copy and paste all of this code to that C# file and save it.
using UnityEngine;
using System.Collections;
public class Bird : MonoBehaviour {
// Movement speed
public float speed = 2;
// Flap force
public float force = 300;
// Use this for initialization
void Start () {
// Fly towards the right
GetComponent<Rigidbody2D>().velocity = Vector2.right * speed;
}
// Update is called once per frame
void Update () {
// Flap
if (Input.GetMouseButtonDown (0))
GetComponent<Rigidbody2D>().AddForce(Vector2.up * force);
}
void OnCollisionEnter2D(Collision2D coll) {
// Restart
Application.LoadLevel("game");
}}
Similarly create a C# script again by right click in project panel and rename it as Camera Follow it will follow your bird ,
=> copy and paste this Script in that file
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour {
// The Target
public Transform target;
// Update is called once per frame
void Update () {
transform.position = new Vector3(target.position.x,
transform.position.y,
transform.position.z);
}
void LateUpdate () {
transform.position = new Vector3(target.position.x,
transform.position.y,
transform.position.z);
}
}
10- Now go to hierarchy panel and select the prefab of bird and go to add component:
First you will add Rigid body 2d , then add circle collider 2d, and bird script your bird's components should look like :
11- Now click on camera in hierarchy panel and go to add component and select camera Follow there and click on button in left of target :
Select The prefab of bird, this will move the camera to wherever the bird will go and the bird will never go out of your sight :
12- Now Add obstacles on your desired place by dragging the obstacle and adding Box collider 2d and rigid body 2D & check "IS KINEMATIC" in its components and press ctrl+S and save it with name as "game".
Extend it by adding more obstacles and extended ground:
Play and Enjoy :)
Email me for any Queries.