Playing multiple animations

Say for instance, I have three animations.
Sword Swing Left,
Sword Swing Right,
Sword Swing Down.

What I want to do is when I hit the attack key, have all three of those plays, back to back back. Right now when I click attack, just one plays. I am sure this has to be done rather simply, but I cant figure out how to do this. Is this something done through scripting or is it better to create another animation that is basically all three grouped together? Thoughts? Thanks!

You could play each individual animation once in one if statement have you looked at this page

I guess I am not following you exactly, These are attack animations, so anytime my character is in attack mode, I want to loop over these three animations until he dies or the enemy dies. Could you give me a little detail about what you mean? I did of course look at the page you referenced.

animation.CrossFade( meleeAttack.name, 0.15f);
animation.CrossFade( meleeAttack1.name, 0.15f);
animation.CrossFade( meleeAttack2.name, 0.15f);

best thing you can do is start a coroutine…

eg:

using UnityEngine;
using System.Collections;

public class Attack : MonoBehaviour
{
    private bool attacking = false;
    private bool isDead = false;

    void Update()
    {
        if(!isDead  !attacking)
        {
            StartCoroutine(Attack());
        }
    }

    IEnumerator Attack()
    {
        attacking = true;

        animation.CrossFade("attack1");
        yield return new WaitForSeconds(animation['attack1'].length);
        
        animation.CrossFade("attack2");
        yield return new WaitForSeconds(animation['attack2'].length);

        animation.CrossFade("attack3");
        yield return new WaitForSeconds(animation['attack3'].length);
       
        attacking = false;
    }
}

Did not test the above code, and of course there’s allot of ways you can do it

that worked like a charm. I think the issue was that I was never “waiting” until an animation completed before starting another one. Thanks for the insight and answer!

My pleasure man…best of luck

Also see CrossFadeQueued