Can you force an animation to finnish?

0 favourites
  • 13 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Short version

    I need to know if there is an action or condition in construct that will essentially make an animation play out entirely no matter what.

    Long Version

    so in my game i'm trying to have a block and dodge system where holding the Z key will put you in a block stance, and pressing left or right on the keyboard will make you dodge left and right respectively. So far so good. but the problem comes in with the dodge animation. Right now, the condition I have is this

    Condition: Z key is down

    Sub-event: Right/Left key is pressed

    Action: Set animation to Dodge

    So I set this up and because I want the dodge to shoot you left and right rather quickly, I've given the player character bullet movement that is enabled when the dodge animation is playing and gets turned off when it's not.

    But here's the problem

    Because of my conditions, if i'm not holding the Z key and the right/left key, then the dodge animation just stops halfway through and the bullet movement is still there, so my character just glides across the floor till they hit the wall. If i hold both the Z key and the left or right key until the animation is over, then everything works fine, but if I don't, then i've got problems.

    So I essentially need a way to make sure that the entire animation plays regardless of whether I'm holding the z and left/right key throughout the entire animation. I've been trying to come up with some roundabout ways to make this happen, but I just need to know if there is a convenient action that could just force an animation to play out entirely. I'll post the capx. below.

  • The other animation that plays (which I assume is an idle animation?), set it up so that the animation is only triggered if Dodge is not playing.

  • Well.. you kinda did'nt post the capx down below ^^

    Also... you can make an instance variable that activates when the player is doing the required stuff for the animation to play, wait the amount of time that is needed for the animation, set the value of the instance variable to something else and it should end up fine :) Post the capx and I'll show you, or PM it to me. Or something... this is very hard since I don't have the capx but I can probably solve your problem maaaaate

  • Would setting the animation to loop only once, and then having "on animation finished" check to see if it should be replayed again or not work?

    In other words, when the animation finishes it restarts if the key is down, otherwise it ends after that loop.

  • That can work - you can also add a condition so that your player's action only goes through if you're not in block state. You would do that by checking for which animation is playing, then inverting that condition.

  • Yes you can, but you have to Greece it up a bit, and it helps if you are Hungary.

    Otherwise Netherlands will help you, but if you ask a different way Samoa may help you.

    Uganda do that, or eat some Turkey?

  • Very helpful! Thanks, I'll keep that in mind.

  • Gah, forgot to put the link in, here it is

  • The other animation that plays (which I assume is an idle animation?), set it up so that the animation is only triggered if Dodge is not playing.

    So I added this condition to my Idle animation trigger

    Is animation "Dodge" is playing (inverted)

    But i still have the same problem, if I stop holding the left or right key, the animation just stops midway and the bullet behavior persists. I've tried a couple of things myself but now i've just reversed my problem. Now if I let go of the left or right key the animation still plays (yay!), but now if I let go of the z key mid animation, they animation will just stop and I go back to having the same problem I had before (boo!)

  • Add an inverted 'Dodge' is playing to event 35

  • Add an inverted 'Dodge' is playing to event 35

    It worked! thanks! but could you explain to me why it worked? so if i run into this problem again, i;ll know what to do?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Event 35 states that when the player releases the Z button it sets the animation to Idle, so this was happening regardless of any other events where Z button is used. In another event you trigger the Dodge anim when Z is down and left or right is pressed but as soon as you release Z the Idle animation will always kick in regardless (but it will still run the Block logic and movement). 'On Button Released' is quite a powerful event. If you find that Idle is overriding future logic I would look back at this event since it is the main one I found that triggers the Idle animation.

  • newt Are USA? (are you ok?)

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