I'm creating a 2D game in which each possible direction of movement for the player, (Up, Down, Left, Right), has its own distinct animation, i.e., they aren't rotations of each other. Currently I am using a FSM design to manage this, but its getting messy already, and I know it will only get worse.
For example: (in Lua)
StateComponent = {
states = {
walking_left = {set_animation("walking_left")},
walking_right = {set_animation("walking_right")},
...
}
},
Now say I want to add attacking, the collection of states then becomes:
StateComponent = {
states = {
walking_left = {set_animation("walking_left")},
walking_right = {set_animation("walking_right")},
...
attacking_left = {...},
attacking_right = {...},
...
}
},
Okay, but now what about opening up a chest from each different side... This quickly becomes very complex. I read about a using a Behavior Tree, but it doesn't seem to support the discrete division of states necessary for having a different animation for walking/attacking/etc in each cardinal direction. What kind of design would be elegant and scalable for this problem? Or how else might I represent these states?
stats = { walking = { left, right ...}, attacking = { left, right .. } ... }
, It'd be a small change, but it's more organized than simply throwing it in a big table. \$\endgroup\$