Alternating "Attack" flipbook animations
Project Background Overview
I'm currently designing a top down paper 2d game. My player sprite is capable of moving in 4 different directions, and attacking in 4 different directions. (Up, Down, Left, Right) For each directional attack, there are 5 flipbooks. (attack_up0, attack_up1, etc )
I'd like the animations to consecutively play one after the other. So if the player is facing up, and they press the attack button once, it will play "attack_up0" flipbook in its entirety, then, should the player press attack again, and they are still facing the same direction; it will play "attack_up1"flipbook in its entirety. This same logic would ideally apply to the other directional states as well.
I have an enum of different directional states, which I check inside my custom animation state machine function to check which direction my character is moving in, and selecting the appropriate value for that direction.
If not attacking it continues the branch to see whether they are moving, or they are idle. It will update the flipbook accordingly if the player is not attacking.
Now here is where things become hazy.
I've been trying to think of a way to implement this attack system, but I'm afraid I'm going about the logic in a wrong way. I feel I have to manipulate some variables, or some flipbooks somehow in the event graph, and have that communicate with my animation state machine, but I have no idea how to go about doing that.
The screenshot below shows my attempt, My first thought was to have an integer "num swings" variable to increment every time a player attacks, to see which flipbook we are currently on. I used similar logic with comparing the last move direction to work the same as an attack direction.
There is an if/else branch, which then makes use of that "combo code" (if I continue down this logic pathway, I'd have multiple if/else branches for each attack state, what you see in this screenshot below is for the attack_up direction)
Also here is a current look at the event graph. (which I may have to add some "Sprite on flipbook end event? set looping logic? get total num frames divided by total duration? I really have no idea where to go from here.)
Follow this question
Once you sign in you will be able to subscribe for any updates here