Dead Animation

Target.cs

Size: 0.37 KB

You need to login to download this file.

  1. Add the Target.cs script on to the character
  2. Add the animation to the controller
    1. Animations are available for free on Mixamo

  1. Add the following code to the character behavoir/movement script (so the character will stop moving if it's dead)
private Target targetScript;

void Start(){
targetScript = GetComponent<Target>;
}
 void Update()
    { // Check if the targetScript is not null and if the health is <= 0
        if (targetScript != null && targetScript.health <= 0f) 
        {
            // Stop agent movement
            agent.isStopped = true;
            return; // Stop the update method because the enemy is dead
        }
}

recommended