How do I transition between different animations?

I’m creating an FPS melee combat system (in which both arms are visible). I have created two attack animations along with an idle animation. The idle animation is specific to the left arm, therefore the right arm does not move during the idle animation. However, during the attack animations both arms move simultaneously. I have created a C# script that will play the animations when a certain key is pressed,but I came across a problem. In the beginning of the game the idle animation is playing on the left arm
(like it’s supposed to), however, when I play the attack animation on the right arm, the left arm stops playing the idle animation all together. I have been trying different ways to fix this but nothing seems to work. Is there a way that can cross fade between the animations? PLEASE HELP

here is the script I created :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ArmAnims : MonoBehaviour {

	void Start ()
	{
		GetComponent<Animation>().Play("Idle_Left_Arm");
	}

	void Attack1()
	{
		GetComponent<Animation>().Play("Attack1_Right_Arm");
	}	
	
	void Attack2()
	{
		GetComponent<Animation>().Play("Attack2_Right_Arm");
	}
	
	void Update()
	{
		if (Input.GetButtonDown("Fire1"))
		{
			Attack1();
		}
		if (Input.GetButtonDown("Fire2"))
		{
			Attack2();
		}
	}

}

Use the transitions tool in the Animator state machine. When you get input from the player in code change a Bool in your Animator component like isAttacking1, and set a transition to Attack1 with the condition isAttacking1 = true in the editor. If you need to do more from there you can attach a script to the State object and access OnStateEnter() and OnStateExit().

Rather then using the script to change between 2 animation, try making and animation controller and assigning necessary value to have the transition between the 2 animations.

check out the above link to see how to use the animation controller.