How do I make an uppercut with 2 buttons, down and pressed?

2 favourites
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hi all,

    I'm new to Contruct 3. For learning purposes, I use sub-zero sprite and trying to recreate all the movements on the keyboard.

    I got stuck with an uppercut.

    I assigned down-key --> arrow down to sitting animation, on arrow-down released I have idle animation.

    And I need the uppercut animation to appear while I hold down the down arrow and press W.

    This code doesn't work

    Event: Keyboard: arrow-down is down --> PlayerAnimation: Sitting

    Sub-Event Keyboard: on W pressed --> PlayerAnimation: UpperCut

    Please help!

  • Could be a few different things getting in the way, depending on how things are setup. Have you tried the two conditions under one action, rather than one main condition and a secondary sub condition?

    EDIT: so something like

    Event: Keyboard: arrow-down is down --> PlayerAnimation: Sitting

    Second Event

    Keyboard: arrow-down

    Keyboard: on W pressed --> PlayerAnimation: UpperCut

    EDIT 2: Not sure if this makes any sense, I'm still waking up, and half asleep lol

  • Event: Keyboard: arrow-down is down --> PlayerAnimation: Sitting

    Sub-Event Keyboard: on W pressed --> PlayerAnimation: UpperCut

    I think what happens is that the first event is running on every tick, and "Sitting" animation immediately replaces "UpperCut" animation.

    Try these three events:

    arrow-down is down
    PlayerAnimation "UpperCut" is NOT playing
     --> PlayerAnimation: Sitting
    
    
    on W pressed 
    arrow-down is down
     --> PlayerAnimation: UpperCut 
    
    
    Player on UnpperCut animation finished
     --> PlayerAnimation: change to something else
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think the issue is that the crouching animation is playing WHENEVER the arrow key is down and the uppercut, only when W is pressed.

    So what ends up happening is that the crouching animation is played, then for a brief moment an attempt is made to play the uppercut animation when W is pressed, but because the down arrow is continuously pressed, the crouching animation takes precedence.

    I think that you need to set a boolean variable when you press W to indicate that an attack has started and while that variable is true don't play the crouching animation, then it won't step over the uppercut one.

    You will need another event to know when the uppercut is complete, so you can reset the boolean and allow the crouching animation to play normally.

  • > Event: Keyboard: arrow-down is down --> PlayerAnimation: Sitting

    > Sub-Event Keyboard: on W pressed --> PlayerAnimation: UpperCut

    I think what happens is that the first event is running on every tick, and "Sitting" animation immediately replaces "UpperCut" animation.

    Try these three events:

    > arrow-down is down
    PlayerAnimation "UpperCut" is NOT playing
    --> PlayerAnimation: Sitting
    
    
    on W pressed 
    arrow-down is down
    --> PlayerAnimation: UpperCut 
    
    
    Player on UnpperCut animation finished
    --> PlayerAnimation: change to something else
    

    Works like a charm! Thank you!

    Now I know the trick, I had similar trouble with Dragon tail kick.

  • I think the issue is that the crouching animation is playing WHENEVER the arrow key is down and the uppercut, only when W is pressed.

    So what ends up happening is that the crouching animation is played, then for a brief moment an attempt is made to play the uppercut animation when W is pressed, but because the down arrow is continuously pressed, the crouching animation takes precedence.

    I think that you need to set a boolean variable when you press W to indicate that an attack has started and while that variable is true don't play the crouching animation, then it won't step over the uppercut one.

    You will need another event to know when the uppercut is complete, so you can reset the boolean and allow the crouching animation to play normally.

    I've tried to play with boolean previously, but I was using them wrong. I'll try your solution as well! Thank you!

  • The boolean solution works, but there's a little more code in there.

  • Hey guys!

    I have another problem, I can't solve it for several days already.

    I'm trying to emulate SubZero's Ice Freeze, like Down, Forward, Low Punch

    I know how to make a combo with the same button pressed several times, but in this case, I need to press 3 different buttons, and only then play Ice Freeze animation.

    As I understand in Construct when you create an event you can add only once "On Key Pressed", every other condition or sub-event will give only the option "Key is down". Am I right or I missed something?

    Here is what I did

    I don't know if there is another way to solve it, but I'm struggling to set the timer object here. It's not working properly because it doesn't consider how fast you pressed the buttons.

  • when you create an event you can add only once "On Key Pressed", every other condition or sub-event will give only the option "Key is down".

    These are two different kinds of events. "On" event is a trigger, it fires only once when the key is pressed. Only one trigger is allowed per event. "Is" event is a condition, if this key is down, the event will run every tick, until the key is released.

    So the easiest way to fire the event once all three keys are pressed is this:

    On D pressed
    Is DownArrow down
    Is RightArrow down
    

    But of course it doesn't take into account how fast the keys were pressed and in what order. You need to save the time when each key was pressed. The array seems like an overkill for me, you can do it with a pair of variables - pressedRight and pressedDown.

    On DownKey pressed
    Set pressedDown to time
    
    On RightKey pressed
    Set pressedRight to time
    
    On D pressed
    Is DownArrow down
    Is RightArrow down
    pressedDown > (time-0.5)
    pressedRight > pressedDown
    ....... Play combo animation
    

    This event will fire when all three keys were pressed within 0.5s and in this order: Down->Right->D

  • Awesome! Really appreciate your help! It's working.

  • This is great to know! Favoriting this thread for reference :)

  • dop2000

    I bought you a coffee and forgot to put a comment, conradhart it's me :)

    Meanwhile, I have another issue. This time I believe is a tough one, not sure.

    How to avoid the rapid transition from one animation to another?

    Let's say if I have a kick on one button and punch on another and then I quickly pressed them one after another, animations interrupts in the middle and you see a mess on the screen.

    Conditions like "if the kick is not playing press punch" and vice versa is not working.

  • Thanks for the coffee!

    It may be a difficult task when character has multiple animations and you need to prioritize and delay actions based on which animation is currently playing.

    It's hard to speculate without knowing your game, but it may be a good idea to use a state machine here. Assign a state to the character when an action starts, for example, "kick". Wait for the animation to finish (or use Timer behavior to wait a certain time), then reset the state to "idle". Allow new actions to occur only when the state is "idle".

  • Oh, that's easy than I thought, it worked! Thanks!

    By the way, I don't have a game yet. Just a Sub Zero sprite for educational purposes. My game is only in my head, I solved the problem of character animation and decided that it's time to start making the game.

  • Hi dop2000

    I hope you are doing good!

    Can you explain in general terms, how to do grab in Construct?

    Let's say I have two stick-man characters and besides regular punches, I want to do a few grab animations. As I understand it, I need to create a grab animation for one character and a fold/fall animation for another, and then just use the physics of the engine?

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