# Unity 2D Tutorial (ver 4.6) – Flappy Bird part 2

#### This is the tool where you are going to code, now replace that code with this:

```using UnityEngine;
using System.Collections;

public class FlappyBirdScript : MonoBehaviour {
//We are going to declare the initial velocity of the bird to be equal to zero
//vector3.zero = 0,0,0
private Vector3 velocity = Vector3.zero;
//Lets declare a vector that controls the gravity, we aren't going to use the Unity's Physics this time
public Vector3 gravity;
//It's time to declare the vector which is going to define the jump of the bird
public Vector3 jumpVelocity;
//Now we declare a bool that it's going to control the first touch of the screen
//or if the player pressed the space key
private bool started = false;
//We need to declare the maximun velocity of the bird rotation
public float topRotationVelocity;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update (){
//If the player pressed the space key or clicked the mouse for the first time
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) {
started = true;
}
}

//This is the Update function for the physics, it's slower than the Update Function above
void FixedUpdate () {
//We add the gravity to the velocity (So the bird goes down)
velocity += gravity * Time.deltaTime;

//If the player pressed the space key or clicked the mouse for the first time
if (started == true)
{
//The game starts only the first time
started = false;
//The velocity receive an impulse, and the bird goes up
velocity.y = jumpVelocity.y;
}
//We pass the velocity and change the transform Y position of the bird
transform.position += velocity * Time.deltaTime;
//It's time to declare an angle for the bird rotation
float angle = 0;
if (velocity.y >= 0) {
//We change angle, if it is positive the bird'll look up
angle = Mathf.Lerp (0, 25, velocity.y/topRotationVelocity);
}
else {
//We change angle, if it is negative the bird'll look down
angle = Mathf.Lerp (0, -75, -velocity.y/topRotationVelocity);
}
//Time to rotate
transform.rotation = Quaternion.Euler (0, 0, angle);
}
}
```