using System.Collections; using System.Collections.Generic; using UnityEngine; 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(); anim = GetComponent(); } // Update is called once per frame void Update () { if (isDead == false) { if (Input.GetMouseButtonDown(0)) // Left click { rb2d.velocity = Vector2.zero; rb2d.AddForce(new Vector2(0, upForce)); anim.SetTrigger("Flap"); } } } void OnCollisionEnter2D(Collision2D collision) { rb2d.velocity = Vector2.zero; isDead = true; anim.SetTrigger("Die"); GameControl.instance.BirdDied(); } }