How do I make attack animation?

1 favourites
  • 9 posts
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • Hi there!

    I have this player, as you can see in the image bellow, with the all animations, but one!

    When I press the button to attack or shoot, the shot comes out but he doesn't move or simply don't activate the "attack" anim...

    What am I doin' wrong here?

    A little help please...

  • It would be more useful to show what you did on the event sheet in regards to animations, or better yet post your project file, as animation events can get complicated.

  • This is the event sheet with the code that I used:

  • just add "not attacking" condition to your idle animation that is always happening (every tick).

    the attack animation IS happening but its being interrupted by lines 8 and 9

  • also consider making a variable called "state" on the player. Then change this to the state you want your character to be in...

    states:

    "normal"

    "attack"

    "defend"

    "dying"

    "dead"

    "lowhealth"

    etc...

    then set and use those states to differentiate code... just make sure you always set them with one action, and end them with some other event like... animation is now over.

    so in your attack, hit the button set state to "attack"

    then make an event trigger when attack animation finishes, set the state back to normal.

    then your idle animation can be triggered only if player state = "normal"

  • one thing I do that is helpful... I have another var on my characters called "prevState". So when I enter them into some new state, I remember their previous state, then when this new state ends, I put them back into the state they were in when originally (just incase that is not the default state).

    BUT this is only if you have lots of complex states. For example if you have an "invisible" state but could still be "stunned". So here you'd want to the stun code and animation run whether they were invisible or not, but if they were invisible, you'd want to return their state to "invisible" when the stun is over.

  • Thnx for the help!

    I've done it the dude is playing the attack animation!

  • Thank you,

    The STATE "mechanic" is indeed very helpfull!...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • for more on "state machines" check out this link. (the concept can be applied to lots of things in life - even a subway turnstile)

    en.wikipedia.org/wiki/Finite-state_machine

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)