Problem with multiple animation Controlle Script

Hello guys,

I have problem when playing animatons when I press a joystick button, only the two first animations work, but the 2 last are not working

if(Input.GetButtonDown("Fire1")){
	     //    Instantiate(AttackEffect, transform.position, transform.rotation);
 //animation.Play("gogo_fire");
       // audio.PlayOneShot(AttackSound);
       
         _animation.CrossFade(Sword_Anim.name);
       
walkSpeed = 1.0;
trotSpeed = 1.0;
}
if(Input.GetButtonUp("Fire1")){
walkSpeed = 14.0;
trotSpeed = 16.0;
}

	if(Input.GetButtonDown("Fire2")){
	     //    Instantiate(AttackEffect, transform.position, transform.rotation);
 //animation.Play("gogo_fire");
      // audio.PlayOneShot(AttackSound);
       
         _animation.CrossFade(Sword_Anim2.name);
       
}
		
	if(Input.GetButtonDown("Fire3")){
	     //    Instantiate(AttackEffect, transform.position, transform.rotation);
 //animation.Play("gogo_fire");
     //  audio.PlayOneShot(AttackSound);
       
         _animation.CrossFade(Sword_Anim3.name);
        //animation.Blend("gogo_sword2");
       
}

if(Input.GetButtonDown("FireJoy")){
	     //    Instantiate(AttackEffect, transform.position, transform.rotation);
 //animation.Play("gogo_fire");
      //  audio.PlayOneShot(AttackSound);
     
         _animation.CrossFade(Sword_Anim4.name);
}

Please help :cry:

help :cry:

Okay, so what you are saying is that only “Fire1” and “Fire2” works, which plays Sword_Anim and Sword_Anim2 right?

There are a lot of things that can make this go wrong, so here is a little checklist:

1: Is the buttons “Fire3” and “FireJoy” hooked up to a joystick button and do they work at all? Go into: Edit - Project Settings - Input. And make sure the buttons are set up correctly. If they are then put a debug log in the script to print out if they are actually responding when pressing a button.

2: Are the animations Sword_Anim3 and Sword_Anim4 referenced in the editor inspector of this component? Go into the editor inspector of this gameobject and check if those two animations are referenced in the same way the two first animations are.

3: Also are the animations referenced in the Animation component itself? If the animation component does not have them it can not play them at all. Go into the inspector of the animation component and make sure they are referenced in the same way as the two first animations.

4: Does Sword_Anim3 and Sword_Anim4 actually have any keyframes and animation in them? Maybe they are actually playing but they have nothing to do in their animation. Check the import settings to make sure everything is alright. If they are made in unity, maybe they did not get saved properly?

5: If you are getting any errors or warnings or messages in the console, then include them with your question.