Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Bird : MonoBehaviour {
  5.  
  6. public float upForce = 200f;
  7.  
  8. private bool isDead =false;
  9. private Rigidbody2D rb2d;
  10. private Animator anim;
  11.  
  12. // Use this for initialization
  13. void Start ()
  14. {
  15. rb2d = GetComponent<Rigidbody2D> ();
  16. anim = GetComponent<Animator> ();
  17. }
  18.  
  19. // Update is called once per frame
  20. void Update ()
  21. {
  22. if (isDead == false)
  23. {
  24. if (Input.GetMouseButtonDown(0))
  25. {
  26. rb2d.velocity = Vector2.zero;
  27. rb2d.AddForce (new Vector2 (0, upForce));
  28. anim.SetTrigger ("Flap");
  29. }
  30. }
  31. }
  32.  
  33. void OnCollisionEnter2D ()
  34. {
  35. isDead = true;
  36. anim.SetTrigger("Die");
  37. GameControl.instance.BirdDied ();
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement