Animation with same key.

Good morning, pressing a keyboard key, starts an animation but I want that when I press it again, start a new animation blocking the first. How can I write the code?

Given that you know you will only have to switch between 2 animations you can use a bool like below. If you want to cycle through more than 2 animations you can use a switch structure (also below)

bool firstAnimation = true;

if(Input.GetButtonDown("Space")
{
     if(firstAnimation)
     {
          firstAnimation = false;
          animation.play("Animation-A");
     }
     else
     {
          firstAnimation = true;
          animation.play("Animation-B");
     }
}
int animationID = 0;

if(Input.GetButtonDown("Space")
{
     switch(animationID)
     {
          case 0:
               animationID++;     //Increment the ID to switch to the next one at the next call
               animation.play("Animation-A");
               break;
          case 1:
               animationID++;
               animation.play("Animation-B");
               break;
          case 2:
               animationID = 0;     //Reset the ID to 0 after the last animation was played to start the loop again from the first animation
               animation.play("Animation-C");
               break;
     }
}