Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var health : int;
- var theDamage : int = 50;
- function OnCollisionEnter2D(coll: Collision2D) {
- if (coll.gameObject.tag == "Enemy")
- if (coll.gameObject.tag == "bullet")
- health -= theDamage;
- }
- function OnTriggerEnter2D(collienter : Collider2D) {
- if(gameObject.tag == "Bullet")
- {
- health -= theDamage;
- }
- if(gameObject.tag == "Enemy")
- {
- rigidbody2D.isKinematic = true;
- }
- }
- function OnTriggerExit2D(collienter : Collider2D) {
- if(gameObject.tag == "Bullet")
- {
- }
- if(gameObject.tag == "Enemy") {
- rigidbody2D.isKinematic = false;
- }
- }
- function Start () {
- health = 100;
- }
- function Update () {
- }
- function dead() {
- if(health <=0) {
- Destroy (this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement