protected override void Update() { if (enemyHealth.getHealth() > 0 && playerHealth.getHealth() > 0 && baseHealth.getHealth() > 0) { if (body != null && body.velocity.magnitude <= 0.1f && !nav.enabled) { body.isKinematic = false; nav.enabled = true; } bool playerFind = Vector3.Distance(gameObject.transform.position, player.position) < Vector3.Distance(gameObject.transform.position, baseObject.position); if (playerFind) { nav.SetDestination(player.position); } else { nav.SetDestination(baseObject.position); } } else { nav.enabled = false; } }
protected virtual void Update() { if (playerHealth.getHealth() <= 0 && baseHealth.getHealth() <= 0) { anim.SetTrigger("GameOver"); restartTimer += Time.deltaTime; if (restartTimer >= restartDelay) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } } }
void Update() { timer += Time.deltaTime; if (timer >= timeBetweenAttacks && enemyHealth.getHealth() > 0 && baseHealth.getHealth() > 0) { if (attackToPlayer) { Attack(true); } if (attackToBase) { Attack(false); } } if (playerHealth.getHealth() <= 0 || baseHealth.getHealth() <= 0) { anim.SetTrigger("PlayerDead"); } }