private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { collision.GetComponent <HealthScript>().dealDamage(damage); spawnScript.enemyDied(); Destroy(this.gameObject); } }
// Update is called once per frame void Update() { if (healthScript.getDead()) { playerScript.addXP(expDrop); spawnScript.enemyDied(); if (Random.Range(0, 100) <= 15) { Instantiate(drop, transform.position, transform.rotation); } Instantiate(death, gameObject.transform.position, Quaternion.identity); Destroy(this.gameObject); } }
// Update is called once per frame void Update() { if (healthScript.getDead()) { playerScript.addXP(expDrop); spawnScript.enemyDied(); spawnScript.shooterDied(); if (Random.Range(0, 100) <= 15) { Instantiate(drop, transform.position, transform.rotation); } Instantiate(death, gameObject.transform.position, Quaternion.identity); Destroy(this.gameObject); } gameObject.GetComponent <Rigidbody2D>().velocity = Vector3.zero; }