How do I stop an action from running once started?

Get help using Construct 2

Post » Wed Sep 09, 2015 9:44 pm

I found an issue while trying to program my character to use a jetpack to fly. I basically told it, on jump, make "jumpsequence = 1" (local static variable) and so on another event, when up arrow is pressed, "jumpsequence = 1", and Platform is NOT on floor, (okay, those were the conditions, now I will sum up the actions --> ) basically make him stay in the air. When Platform IS on floor, make "jumpsequence = 0". This allows him to do this action over and over again. This works.. but the problem is this: When he is in the air, I want him to run out of jet stamina and need to land before using it again. So, I programmed it to basically say, "when he is in the air, and flying, wait 4 seconds, then have him drop." However, if the player decides to make him drop early, the "wait 4 seconds" action still runs! So when the player goes to jump and fly again, because the last "wait 4 seconds" is still running, he lands early. I programmed it to basically say, "when player is in air, "EarlyLand" = 1. If "EarlyLand = 1" then it starts the 4 seconds. However, if he lands early and the 4 seconds have already started, and yet when he lands, "EarlyLand = 0" then why does the action "wait 4 seconds" not stop? To sum up my issue, why is it that once an action is started by "a variable equaling 1" you can't stop the action when the "variable becomes 0"? If anyone is too confused about this to help, then I will gladly send a picture of my events. Since this website doesnt allow pics to be uploaded or attached, I would have to send it to you by email or some other means. Thank you.
B
11
S
1
Posts: 27
Reputation: 583

Post » Wed Sep 09, 2015 10:09 pm

Don't use Wait, you can't stop it. Use the Timer behaviour, and you have full control over it.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Thu Sep 10, 2015 2:07 am

Thank you so much blackhornet! It all works now! I had no idea there was a Timer behavior!
B
11
S
1
Posts: 27
Reputation: 583


Return to How do I....?

Who is online

Users browsing this forum: newt, Yahoo [Bot] and 6 guests