private void OnCollisionEnter(Collision collision) { if (omaeWaMouShindeiru) { if (collision.gameObject.tag.Equals("Wall")) { GetComponent <Animator>().enabled = true; animationController.enabled = true; faceTarget(); animationController.Animate("attacked"); StartCoroutine(dieAfterDelay(animationController.animationStateLength())); } } }
void FixedUpdate() { if (stats.getHP() <= 0) { animationController.Animate("death"); StartCoroutine(death(animationController.animationStateLength() * 2f)); } inAmbush = GameObject.FindGameObjectWithTag("Manager").GetComponent <AmbushManager>().isAmbushActive(); agent.SetDestination(player.transform.position); float distance = Vector3.Distance(player.transform.position, transform.position); if (inAmbush) //if in ambush, stop navigation and panic flip { agent.isStopped = true; //animationController.Animate("flip"); } else if (distance > agent.stoppingDistance) //if not in ambush and not within stopping distance, start navigation { agent.isStopped = false; } else if (distance <= agent.stoppingDistance) //if not in ambush and within stopping distance, stop { agent.isStopped = true; } //Animations if (stats.getHP() <= 0) { animationController.Animate("death"); //death } else if (stunned) { animationController.Animate("attacked"); //attacked } else if (inAmbush) { animationController.Animate("flip"); //if in ambush and not dead or attacked, panic flip } else if (!inAmbush && agent.isStopped) //if not navigating, idle { animationController.Animate("idle"); } else if (!inAmbush && !agent.isStopped) //if navigating, walk { animationController.Animate("forward-walk"); } }