Beispiel #1
0
    /*
     * This funcion Kills Unit and Plays Necesary Sounds and Animations
     *
     * */

    public void Die()
    {
        //Stop VavMesh Agent From Moving Further
        agent.enabled = false;
        //Disable Colider to avoid colliding with projectiles when dead
        gameObject.GetComponent <CapsuleCollider>().enabled = false;
        model.GetComponent <CapsuleCollider>().enabled      = false;
        GameController.instance.notifyDeath(this); // Tell controller I'm dead
        //PLAY DIE SOUND
        if (!source_death.isPlaying)
        {
            source_death.PlayOneShot(death[Random.Range(0, death.Length)], 0.5f);
        }

        animScript.Die();

        Destroy(gameObject, 1.5f);
    }