I am trying to get a simple attack animation to override both walk and idle animations when its played by placing the attack animation on a higher layer than both the walk and idle animations. However when using CrossFade the attack animation never occurs and the walk or idle animations continue as normal. If I change CrossFade to Play it does override both the walk and idle animations. Anyone know what I am doing incorrectly?
void Start ()
{
unit = GetComponent<RTSUnit>();
animation["idle"].layer = 0;
animation["walk"].layer = 0;
animation["attack"].layer = 1;
animation["attack"].wrapMode = WrapMode.Once;
animation["hit"].layer = 2;
animation["hit"].wrapMode = WrapMode.Once;
}
// Update is called once per frame
void Update ()
{
}
//Animation for when the unit is moving in a direction
public void Walk ()
{
print("Walk");
animation.CrossFade("walk");
}
//Animation for when the unit is sitting idle
public void Idle ()
{
animation.CrossFade("idle");
}
//Animation for when the unit is attacking an enemy
public void Attack ()
{
print("ATTACK");
animation.CrossFade("attack");//,PlayMode.StopAll);
//animation.CrossFadeQueued("idle", 0.3f, QueueMode.CompleteOthers);
}
//Animation for when the unit receives a hit from the enemy
public void Hit ()
{
animation.CrossFade("hit", .1f, PlayMode.StopAll);
}
//Animation for when the unit is killed
public void Death ()
{
}