1 Action, Multiple Animation

Hey Everyone,

Is there a way to have multiple animation for the same action ?
I intend to have 2-3 different animations when the player dies and want it to play those randomly.

Player gets hurt > Random Death Animation > flash on and off then respawn.

Currently i have the respawning working well, but would certainly like to know how/ if such task is achievable.

thank you for your responses.

Ali

yes you can

if (hulkMood == "H") anim4.Play("hulk-happy");
elseif (hulkMood == "S") anim4.Play("hulk-slow");
elseif (hulkMood == "F") anim4.Play("hulk-fast");

Note you can also concatenate differents bits and bobs to get the animation name

elseif (characterMood == "XX") anim4.Play(GD.characterName + "-angry");

However there are 2 things

  1. all these animations need to be in the same animator
  2. they would have to have similar shape (ie. rigidbody) otherwise the physics will not react correctly

When the player dies, you can have a Random.Range, for each of your death animations.
Like so:

    private void HandleDeathAnimations()
    {
        int i = Random.Range(1, 4); // range is X to Y -1 for ints. [1-3 here]
        switch(i)
        {
            case 1:
                animator.SetTrigger("Death1");
                break;
            case 2:
                animator.SetTrigger("Death2");
                break;
            case 3:
                animator.SetTrigger("Death3");
                break;
        }
    }