Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Bird : MonoBehaviour {
- public float upForce = 200f;
- private bool isDead =false;
- private Rigidbody2D rb2d;
- private Animator anim;
- // Use this for initialization
- void Start ()
- {
- rb2d = GetComponent<Rigidbody2D> ();
- anim = GetComponent<Animator> ();
- }
- // Update is called once per frame
- void Update ()
- {
- if (isDead == false)
- {
- if (Input.GetMouseButtonDown(0))
- {
- rb2d.velocity = Vector2.zero;
- rb2d.AddForce (new Vector2 (0, upForce));
- anim.SetTrigger ("Flap");
- }
- }
- }
- void OnCollisionEnter2D ()
- {
- isDead = true;
- anim.SetTrigger("Die");
- GameControl.instance.BirdDied ();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement