Animation error (Last time I'm asking)

if (Input.GetMouseButton (0))
{
anim.play(“Swing_Left”);
}

if (Input.GetMouseButton (1))
{
   anim.play("Swing_Right");
}

Simple enough, right? Well if I press “Swing_Right” in the middle of the animation for “Swing_Left” it cancels out the previous animation. I want one animation to play uninterrupted and reset before another input is activated.

Edit: As it seems no-one on this site seem to know the answer does anyone know where I could possibly get help with this?

I would use an Animator Controller for this, its a lot easier than doing it in code and a lot more flexible when you want to add more animation states in the future.

The documentation is here: Unity - Manual: The Animator Controller Asset

And there is a video here that explains with an example: The Animator Controller - Unity Official Tutorials - YouTube

Try adding an if statement before you tell the animation to play that checks if the previous animation has finished.
use this:

if (anim.time == anim.length) {
   anim.play("Swing_Left");
}