Questions about interrupted attacks

For questions about using Classic.

Post » Tue Jun 23, 2009 4:31 am

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:



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.
B
2
G
3
Posts: 15
Reputation: 880

Post » Tue Jun 23, 2009 4:58 am

first, use private variables for characters.
[quote="DesignerSpecial":1uj582lx]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.[/quote:1uj582lx]
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

[quote="DesignerSpecial":1uj582lx]why you can switch animations in the middle of the attack. [/quote:1uj582lx]
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.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jun 23, 2009 6:00 am

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.
B
2
G
3
Posts: 15
Reputation: 880

Post » Wed Jun 24, 2009 3:39 pm

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.
B
2
G
3
Posts: 15
Reputation: 880

Post » Wed Jun 24, 2009 5:25 pm

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.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed Jun 24, 2009 7:46 pm

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?



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.
B
2
G
3
Posts: 15
Reputation: 880

Post » Wed Jun 24, 2009 8:59 pm

"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"
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Jun 24, 2009 9:12 pm

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.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed Jun 24, 2009 10:54 pm

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. :oops: Hopefully that will work. Thanks again.
B
2
G
3
Posts: 15
Reputation: 880

Post » Thu Jun 25, 2009 6:21 pm

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?



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.
B
2
G
3
Posts: 15
Reputation: 880

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests