so im making a 2d fighting game and i want to play a punch animation. but it cant play cause its overlapping with the idle animation.
I was following a tutorial for a 2d platformer and got the movement from there. Now i wanted to add punches but it overlaps.
Hey there @AFDave!
So, for things such as this, you could probably use a flag called IsInAttack or something along those lines and add another select to your update animation code for when IsInAttack is true it plays the punch animation instead. When your attack is called, IsInAttack is marked to true and when it’s over, it’s marked to false. I also recommend trying to break up your code into something not called on tick, which is very performance heavy, especially in BPs.
Something you may want to look into is using an Enumerator to determine your State! Then you can do things like Switch on Enum which determines what is done based on current Enumerator. The upside to this is only one option of the enumerator can be true- so you could have the options be
Idle
walking
attacking
blocking
etc. with a bool check for “IsFalling” determining if the character is in the air or not.
Then when you start or finish doing any one of the above things, you set that Enum and then the flipbook changes in your tick based on that! It’s pretty standard stuff for a 2D fighter, most tutorials for something like that will definitely use one.
You could also use a bunch of booleans, but better to have it all in one variable.