Ideas for how to make a character do something while walking

I’m trying to blend between two animations, one where the character is walking/running with just the standard animation and then when the player presses the fire key the character raises their arm/weapon etc.

This is pretty simple by itself, but with two different sprite sheet animations they are not in synch and the legs and what not look kind of jerky when going from: Standard walk animation → do something while walking animation → back to Standard walk animation.

One thing I tried is I had the two animations ( identical except one with arm lowered, one with arm raised ) broken into single frame animations that I then put into two blend-trees that were then both dependent on a modulus in my script that would cycle through 1 - 24 each second ( the amount of frames in each animation ).
This worked perfectly and I thought I had it fixed, but an apparent side-effect of this is now when transitioning from jumping back to walking there’s this weird flutter that I can’t for the life of me figure out how to fix.

I’m pretty new to all this and I’m not sure if I’m just making this way harder on myself than it should be… what are some techniques people usually use to do this type of animation?

If you animate the walking and the arm/weapon separately you can put the arm blend tree on its own animator layer and it will act independantly in the controller. I think they go over it in detail in the official intro to unity 2d video on the learn page.

Thanks man, got it working! I had watched the live training one but not the intro with that useful nugget, that’s actually a very powerful feature. I had been animating my character in external programs and getting them into Unity with frame by frame sprite sheets. Now I’m in the process of redoing the character and the animations within Unity, I can already see this is going to open up a lot more possibilities not to mention save on file size.

Are there any disadvantages to animating the character within Unity instead of importing frame by frame sprite sheets? I feel this is too nice for there not to be some catch lol

Man oh man! I felt the exact same way when I first started playing with the Animation tools along with Mechanim. It seemed too easy and too good. I suppose deciding which is better really boils down to you, the developer. I enjoy both ways but I prefer using anything that keeps me inside the Unity editor doing things the Unity way. The Animator is a little more time consuming but you get so much more control over every aspect of your animation and you don’t need to worry about redrawing or editing a sprite to make changes, you just simply tweak your animator parameters and voila! I’m glad this solved your problem!