Animation transitions in sprite based game

How to handle animation transitions between two different actions in a sprite based game?

Lets say I have three states:

Idle
Walking_Right
Running_Right

For sake of simplicity lets think only in one direction (right).

To handle the animation I operate over the entity velocity: 0 render idle animation, (0,3] walking animation, and (3, MAX_SPEED], running animation.

The walking/running animation speed is based on entity velocity, since it feels like accelerating.
It works nicely, but the transition isn’t “smooth”, hence I’m thinking in create some transition animations as:

Idle->walking
Idle->running
walking->running
running->walking
walking->idle
running->idle

But we can see that this grows exponentially (combinatorics), since I can have more states (as duck, rolling, jumping) also the 8 directions.

I have heard about " blend tree" , besides it makes sense in a skeleton animation based game. I could not see any way to work with sprite based animations, but, nevertheless, I found some online guides/tutorials explaining about “blend tree” in sprite animation

2d sprite animation with blend tree

Is possible to use a blend tree to solve this problem? It makes any sense?

Besides that, in the end, I will also need to write a FSM or HSM or any kind of push automata to handle these transitions and states.

Is there anywhere a documentation explaining how to handle that inside a game? Which data structures should I need? what is a good approach to this problem? How should I model my game entity?

Best regards.

http://www.gameprogrammingpatterns.com/state.html
Maybe this could help you (also the other chapters of the book are worth it, but this I think it’s related with your question)

1 Like

YEs. I have read all that book already. anyway thank you for you answer.

I was more trying to learn how to blend animations, but as far as my research gone is not possible in cell/sprite based animations only skeleton/channels. And that makes sense.

I need to draw my own transition animations and play them in right time synced with the timestep.

I don’t want to add skeleton and real 3d rendering in my game to keep it simple. I will use 3d coordinates for entity movement, but in the end will be a 2d game.

Thank you for your reply.