Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var health : int;
  2. var theDamage : int = 50;
  3.  
  4.  
  5. function OnCollisionEnter2D(coll: Collision2D) {
  6.         if (coll.gameObject.tag == "Enemy")
  7.             if (coll.gameObject.tag == "bullet")
  8.             health -= theDamage;
  9.     }
  10.  
  11. function OnTriggerEnter2D(collienter : Collider2D) {
  12.         if(gameObject.tag == "Bullet")
  13.             {
  14.             health -= theDamage;
  15.             }
  16.         if(gameObject.tag == "Enemy")
  17.             {
  18.             rigidbody2D.isKinematic = true;
  19.             }
  20.         }
  21. function OnTriggerExit2D(collienter : Collider2D) {
  22.         if(gameObject.tag == "Bullet")
  23.             {
  24.            
  25.             }
  26.             if(gameObject.tag == "Enemy") {
  27.             rigidbody2D.isKinematic = false;
  28.             }
  29.         }
  30.                
  31. function Start () {
  32.     health = 100;
  33. }
  34.  
  35. function Update () {
  36.  
  37. }
  38.  
  39.  
  40. function dead() {
  41.     if(health <=0) {
  42.         Destroy (this);
  43.         }
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement