How to Sync the Running and Attack Animations for a 2D Sprite?

IF you look at the 2 and 4 row in the spritesheet that I provided, you will see that in the 2nd row the character is simply running while in the 4th row he is running and attacking at the same time. I wish to blend these 2 animations whenever the player decides to attack. I read about using avatar masks and creating separate layers to animate certain parts of the player’s body for rigged 3D models but I’m not sure if I can take the same approach for 2D sprite. I would also like to extend so that player can also attack while idling. Any ideas how I can do it?

You are facing the same problem a lot of people face when programming. You can either blend everything together and have to attend to every combination of every value of every variable, or your can break a problem down into smaller problems and solve each one independently, then find a way to link the solutions together.

In programming, it’s a “no-brainer”. The only people who think breaking things down into more cohesive solutions is harder are people who haven’t yet become accustomed to doing it that way.

I can’t say whether it’s better for sprites, although I suspect it is.

Anyway, the two solutions for sprites are as follows:

  1. Mash the problem of running and attacking together by creating another row that is both running and attacking.
  2. Separate the arms from the body and animate the arm separate from the body.

The exact details of that would be up to you but, at an high level, I would expect you to create multiple game objects, set the anchors of the dependent game objects (e.g., the arm) to be at the point where it connects with its dependency (e.g., the shoulder), then move the image according to where that connection point is on the dependency object (e.g., as the torso moves, change the position of the arm accordingly).

There might be a better solution. I know that Unity had a pretty neat live session about 2D sprite stuff.

I remember there being multi-layered sprite characters in that.