Questions about interrupted attacks

This forum is currently in read-only mode.
From the Asset Store
126 vocal sound effects interpreted by three different actors divided in: Dialogues, attacking, dying, pains, emotions
  • Hello,

    I just discovered Construct about a week ago and have been very impressed with it so far. Having come from using other editors like OpenBOR and Game Maker, it's already easier and has more of the features I need even at this early stage. However, I'm running into what's probably a pretty noob problem and was hoping someone could point me in the right direction.

    I'm using the following code to make a character (named Pink) that can move back and forth and attack. Pink needs to stop moving when she attacks, thus the "Pinkcanmove" variable. However, I'm running into two problems with this code:

    • If you press attack while walking, the animation flashes one frame for a split second and then she keeps walking. I want to have it so that when you press attack, the command overrides the movement, she stops moving, and the attack animation comes out.
    • If you press left or right during the attack animation, that animation is interrupted and mirrored. I understand the mirroring (there are left and right attack animations), but not why you can switch animations in the middle of the attack. I'd like to stop this from happening.

    Here is the code:

    <img src="http://webpages.charter.net/designerspecial/code.jpg">

    Pink is using Platform movement even though she only moves left and right.

    Sorry to ask, I just couldn't find a solution to this in the Platform tutorial or on the Wiki (but maybe I missed something). Thank you very much in advance.

  • first, use private variables for characters.

    If you press attack while walking, the animation flashes one frame for a split second and then she keeps walking. I want to have it so that when you press attack, the command overrides the movement, she stops moving, and the attack animation comes out.

    this is because the walk animation is overriding it on the same tick or the one after it. You have to implement a check to stop the walk animation from happening if the character is attacking.

    is walking

    character animation Attack not playing >> set animation to walking

    why you can switch animations in the middle of the attack.

    you have to implement another check to see if an attack is playing or not. Construct knows nothing of "attacks" or "characters". All it sees are your events. Add.. animation punch is not playing to the kick events, and vice versa.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for the suggestions. I did switch the global variable to a private one, but I'm not having as much luck with the other fixes.

    • Adding an inverted 'Animation "Punch" is playing' to the walking condition does not help with the problem of the walking animation interrupting or canceling the punch animation (same for Kick obviously). Another issue is that sometimes only one frame of the 3 frame punch animation comes out when pressing attack while walking.
    • The problem with the switching animations in the middle of an attack isn't between Punch and Kick, it's that if the character is facing left and starts to punch and I press right during the animation, she switches to the mirrored punching animation.

    Thanks in advance for any further advice.

  • Hi, sorry to bump this but I'm still having problems. If I release left/right before attacking, everything is fine, but the problem occurs if I continue holding a direction while pressing attack. I tried adding "is walking" and "attack animation not playing" commands, but it does not help. Do you have any other suggestions as to what I might try? Thanks.

  • I suggest using what I call control states. Basically you have a private variable that based upon its label, controls what controls there are. Like this:

    If variable 'mode' is "standing"

    sub event - if "punch" is pressed, set animation to "attack", set 'mode' to "attacking", start ignoring input

    sub event - if "move left" is down, set angle

    What's going on here, is since the events to attack and set the angle are sub events, they only run if the parent event is true. Therefore by changing the variable, you change the control set. Since 'mode' is not "standing" anymore, pressing punch won't make the character attack again because the event doesn't run. Then make a second set of events:

    If variable 'mode' is "attacking"

    sub event - if animation "attacking" is over, set animation to "standing", set 'mode' to "standing", stop ignoring input

    Voila! Using this technique you can make ridiculously complex control combinations easily. This way you also avoid conflicts from having to use bazillions of conditions which makes bugs really hard to track down.

  • Thank you, that is a very good idea and it immediately fixed the problem I was having until I tried adding left and right walking animations. Could you tell me what might be wrong with this updated code?

    <img src="http://webpages.charter.net/designerspecial/code2.jpg">

    If the untoggled commands are turned on, the player freezes when the attack command is entered. Do I just not have them in the right locations? Also, I would think I'd have to turn the 'standing' variable to 0 while the 'punching' variable is at 1, and vice versa - is that correct, and where would I put those commands?

    Thanks again for your patience and help so far.

  • "On ____ Pressed" is a trigger. It happens in only one tick. You can't invert a trigger, it makes no logical sense.

    It's like saying "NOT Trigger once"

    Try "NOT ____ is Down" instead of "NOT On ____ Pressed"

  • What's going on is when you punch without turning the variables off, they both stay on and then both sets of controls are running. So after punching, standing = 1 and punching also = 1.

    Don't use 2 variables (standing, punching). Use one text variable and change that from "standing" to "punching". Otherwise you'll have to toggle each one by hand, whereas using one variable does it all automatically.

  • Makes sense Deadeye, thank you.

    Arima, that sounds like a good idea, I will try it as soon as I learn how to use text variables. I haven't found how to call them yet, but I will look at more tutorials and see if I can figure it out. Thanks for your help so far.

    edit: duh, I forgot to put quotes around the text variable. Hopefully that will work. Thanks again.

  • Guh, this is getting frustrating. Arima's idea of control states worked perfectly until I added walking animations. Now I have all of the same problems as before; attacks playing one frame, being interrupted by walking animations, the character moonwalking, etc.

    Could someone look over this code and let me know if there are any obvious problems?

    <img src="http://webpages.charter.net/designerspecial/code3.jpg">

    I'm sorry to keep asking about this, but I really want to get this issue solved before moving on to anything else. I'm assuming that I'm just missing something, but the last time I had a fairly similar problem with a game creation program and asked in the forums, it turned out to be a bug after all. Might as well be sure it's just me. Thanks in advance.

  • How do you get the condition "Move Left" is down to appear? On my computer selecting mousekeyboard - control is down/on control pressed results it reading: Player 1 "Move Left" is down / On player 1 pressed "Punch".

    You could also try instead of "Pinkbox mode equals punching, set animation to punch" put the set animation to punch action in the punch pressed events instead.

    Aside from that, I'm not sure. You have other code, it could be something in there. I tried recreating it and it works here.

  • The only other code is an Always command to keep the Pink sprites aligned with the Pinkbox (that's shown in an earlier code example) and the Kick section, which is identical to the Punch one except for using kicking animations.

    I will try to post the .CAP file later today so you can see exactly what's happening if that's OK. It might have more to do with the animation speed and a slight acceleration/deceleration in movement than the actual code, and the only way to tell would be to see it in action. Thank you very much for trying to recreate it, your help is appreciated.

  • Hiya DesignerSpecial, have you found the solution to this? I've been trying to for some days now without much luck. Would love to move on with my project as well.

    thx

    ~t

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