Animation interrupt


#1

I am working on an animation for a platform fighting game, and having trouble with the attack animations.

For instance when the player presses the “S” key the character is supposed to do a “back kick”.

I’ve tried two different conditions on the input:

1 - Input.check(Key.S) this causes the back kick to be performed and held in the air as long as the key is held (if looping set to true), and if the key isn’t held long enough the animation wont complete.

2 - Input.pressed(Key.S) this causes the first sprite of the animation to flash quickly before returning back to the “standing” animation.

In part of the update loop I check all the states like speed, direction, onGround etc… and play animations accordingly. It seems like when I use the Input.pressed, the “back kick” animation is interrupted with the standing animation when update finds out that the character has no x-speed. Should I have interrupt the state-checks that play other animations for the duration of the “back kick”, or is there an option of method that give an animation priority to play?


(Martí Angelats i Ribera) #2

The problem is that you interrupt the animation. You need to check that the animation is completed before to play the default one:

if (Input.check(Key.S))
{
	spritemap.play("back kick");
}
else if (spritemap.complete)
{
	spritemap.play("standing"); //or whatever you want
}

Ans set the looping of the “back kick” to false becouse you only want it once.


#3

I see…okay I’ll give it a try…thanks


#4

Awesome thanks! thats all I needed - was to interrupt the movement animations with the attack animations