Alright so I have a character, my game has a punching mode and I have got it so when you hold the mouse button RightPunch is thrown, and LeftPunch is thrown right after that. Now my problem is I am trying to make it so that after the Left Punch, the animations restart so Right Punch is thrown, and then Left Punch… And so on and so on, and looping the animations will no suffice. Can anyone help me out please?
An FSM question came in recently so I tried to use that approach here. This is pseudo-code.
Setup an Enum:
public Punch punch;
public enum Punch {
Left,
Right
}
Start() {
punch = Punch.Left;
}
Update() {
if(input.getPunchKey) {
switch(punch) {
case Punch.Left:
play.punchLeftAnimation;
wait/pause/for x seconds/something;
punch = Punch.right;
break;
case Punch.Right:
play.punchrightAnimation;
wait/pause/for x seconds/something;
punch = Punch.Left;
break;
} // switch
} // if
} // update