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");
}