Running and attacking java problem

Hi, I’m new to programming and I could use a little help. I’m trying to make it so that when my character is running and I hold the attack button that the running attack animation plays.

    function Start () {
animation.wrapMode = WrapMode.Loop;

animation["attack"].wrapMode = WrapMode.Once;

animation["attack"].layer = 2;

animation["run"].layer = 1;

// Stop animations that are already playing

animation.Stop();
}
function Update () {

if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("run");
else
animation.CrossFade("idle");

// Shoot
if (Input.GetButtonDown ("Fire1"))
animation.Play("attack");

//Shoot whilst running
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1 (Input.GetButtonDown ("Fire1")) )
animation.CrossFade("runattack");
}

Make the attack animation’s blend mode ‘additive’

animation["attack"].blendMode = AnimationBlendMode.Additive;

If you play that animation now, it will be played on top of any other animations, i.e. the animation for the lower body.

Thank you very much :slight_smile: