Animation State Machine

0 favourites
  • 5 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Hello there!

    I?ve made some games with C2 so far, but I?m at a loss when controlling animations in an efficient manner.

    I?d like to have several states like, for example:







    But I can?t seen to make the transitions between those states in a clean way. So, how do I make a controller for those animations that doesn?t look like crazy if I need to insert a new animation?

    Also, is there any way to queue animation states?(For example, two idle states or a double jump)

    If you could provide an example I would be very grateful!


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One way to approach it is to separate out each animation to play only when a specific set of events is true.

    eg: play the crouch walk animation if the down and left keyboard buttons are pressed.

    which would look like

    keyboard On Left Arrow is Down-> play crouch walk animation

    keyboard On Down Arrow is Down

    repeat this for each and every type of unique movement you want the player to do.

    To transition between them nicely, you will also want to make use of the "on animation crouch walk" is finished events.

    So after you are done crouch walking you might trigger the play "stand up" animation so it looks nicer and doesn't just POP into place.

    so that would look like

    PlayerSprite On Animation "crouch walk" finished -> PlayerSprite set animation to "standup" (play from beginning).

    If you find that animations are interrupting each other....

    For example. if you player is playing a falling animation and you press left or right and that makes him start walking again in the air. you can make use of the "is playing animation" event. and then invert it and make it a "is NOT playing" event condition


    keyboard on key down "Left"

    (a second condition) PlayerSprite is NOT playing animation "falling" -> play "walk left" animation

    this way the "walk left" animation will only play provided the "falling" animation isnt currently playing.

  • Thanks justifun!

    I?m worried that working with exceptions(ie:when not falling), the code becomes a mess and inserting new animations is a shore. ;o

  • You could give the player a variable playeraction and set it to "walking","falling","jumping","shooting"

    Then instead of checking animation you only have to check which action the player is performing.

    so on left button touched -

    player.playeraction = "walking"

    • player set action to "jumping"

    player compare variable playeraction = "jumping"

    system trigger once

    -player simulate platform pressing jump


  • I've made a variable to tell which animation is playing, and instead of changing the animation when keys are pressed and such, I just change it.

    For the basic platform movement, I check if it's 0 then check if the character is walking, jumping, etc.

    For other things, like using abilities, swimming, going up a ladder, I use other numbers.

    <img src="" border="0" />

    (Sorry for the messy code, I know I could use sub-events to make it look prettier but I haven't got to cleaning it up yet)

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