Beispiel #1
0
    void OnCollisionEnter2D(Collision2D c){
       
        if (c.transform.tag == "Bullet" && !dead) {
            bulPhys = c.gameObject.GetComponent<BulletPhysics>();
            Debug.Log(bulPhys.getDamage());
            Destroy(c.gameObject);
            health = health - bulPhys.getDamage();
            GameObject bloodclone = Instantiate(blood, transform.position, Quaternion.identity) as GameObject;
            if (health <= 0)
            {
                dead = true;
                GetComponent<BoxCollider2D>().enabled = false;
                GetComponentInChildren<Animator>().SetBool("isDead", true);
                gameObject.tag = "Corpse";
                GetComponentInChildren<SpriteRenderer>().sortingLayerName = "Corpses";

            }
		}
	}