I want to implement an animation in my 2d game for when the player character encounters something surprising/scary and staggers backwards a few steps in shock. I'm wondering what's the best/easiest way to implement this. I've come up with a couple of ideas:
1) create a new walk animation for it, and assign the directional suffixes inverted. so when I need the character to step back going right, he will be facing left. implementing it in an action list would require changing the walk animation to the new one, making the character walk to an established marker point, and reset the walking animation to the default one.
2) create a whole new custom animation with a larger sprite, in which the character staggers back a couple of paces moving inside the sprite itself. this will give me more freedom on how to make the animation, but it also means that at the end of the animation the character will be in a different spot from the beginning: so I will either need to "reset" his position having him step forward again within the same animation, or teleport the character as soon as the animation goes back to idle (trying to pinpoint the exact location which I'm sure won't be easy)
They both sound a bit hacky and not super easy to maintain, and I'm not sure about possible other downsides I might not be seeing at the moment. Has anyone gone through something similar for 2d games?
thanks
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Moving the Player's root certainly sounds like the better option.
If you switch your character's Animation engine to Sprites Unity Complex, you could switch to/from a separate "backwards-walking" sub-state with a single Bool parameter. Leaving it as Sprites Unity and changing the walk animation is still viable, though.
Either way, you can move the Actions that update the animation, move the character to a Marker, and then revert the animation, can all be moved to an ActionList asset file - that then has parameters assigned to the dynamic fields (e.g. the Marker to move to). That way, you can re-use the same ActionList whenever such a sequence occurs.
Thanks for the tips!