void FixedUpdate() { if (!isDead) { GetComponent <Rigidbody>().transform.LookAt(player.transform.position); } if (EnemyClear.killGoal == EnemyClear.getKillCount()) { isDead = true; navAgent.isStopped = true; navAgent.enabled = false; rend.material.SetColor(Shader.PropertyToID("_Color"), Color.green); Destroy(gameObject, 2.0f); } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Bullet") { if ((collision.gameObject).GetComponent <Mover>().getType() == type && !isDead) { EnemyClear.countKill(); isDead = true; navAgent.isStopped = true; navAgent.enabled = false; rend.material.SetColor(Shader.PropertyToID("_Color"), Color.green); Destroy(collision.gameObject); Destroy(gameObject, 2.0f); EnnemiGenerator.countEnnemies--; } else if (!isDead) { countWrongPresent += 1; BecomeEnraged(); } } }