private void FixedUpdate() { if (wh.Health >= 10) { //if there is no target in the range if (Monsterr == null) { readyforcombat = false; if (readyforcombat == false) { anim.SetBool("isWalking", false); anim.SetBool("isAttacking", true); S_agent.isStopped = false; S_agent.SetDestination(Soldierwaypoints.position); if (Vector3.Distance(transform.position, Soldierwaypoints.position) < 1f) { NextPoint(); } return; } } //if creature finds one else { readyforcombat = true; if (readyforcombat) { S_agent.SetDestination(Monsterr.position); LookMonster(); anim.SetBool("isWalking", true); anim.SetBool("isAttacking", false); if (Vector3.Distance(this.transform.position, Monsterr.position) >= 1.5f) { S_agent.isStopped = false; } else { S_agent.isStopped = true; } } } } else { wh.Die(); } }
private void FixedUpdate() { if (wh.Health >= 5) { if (Monster_arrived == null) { detected = false; if (!detected) { anim.SetBool("isWalking", false); anim.SetBool("isTerrified", true); villager.isStopped = false; villager.SetDestination(escapepoint.transform.position); // if villager escapes if (Vector3.Distance(this.transform.position, escapepoint.transform.position) < 3f) { Game_User.lastScore += 200; Destroy(this.gameObject); } } } else { detected = true; if (detected) { anim.SetBool("isWalking", true); anim.SetBool("isTerrified", false); villager.isStopped = true; LookToMonster(); } } } else { //Goodbye cruel world :( Game_User.lastScore -= 100; wh.Die(); } }