cooldown between punch

Get help using Construct 2

Post » Fri Nov 08, 2013 1:57 am

i have 2 types of punch

running and idle
both i press A button


what i can do to add a little cooldown to prevent players to cancel the punch
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Fri Nov 08, 2013 2:13 am

Create a timer that when is above a certain number allows you to punch.

For example

Variable punchTimer = 0

Every Tick Add DT to punchTimer

If punchTimer >= 4 and Button to Punch is pressed then
Punch
set punchTimer = 0

Hope that makes sense.
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,667

Post » Fri Nov 08, 2013 2:43 am

LOL
so Obvious

why i didnt think about this
thx a lot
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Fri Nov 08, 2013 2:58 am

It might be better to flip that around ArcadEd. In your example it would be the time since the previous attack that would determine what attack you could perform (rather than time since previous), and I believe he's actually trying to prevent canceling the punch.

I would invert the meaning of your punchtimer like so:

variable punchTimer = 0

every Tick | subtract DT from punchTimer

then actions are only allowed if the punchTimer = 0. You can even prevent changes in direction or other actions that would cancel the punch. In this way, different punch styles can set the punchTimer to different values, so you can have more time to recover from a running punch than a idle punch, for example.

'Course, I could have also misunderstood what he wanted to do, too.
B
15
S
5
G
2
Posts: 24
Reputation: 2,054

Post » Fri Nov 08, 2013 1:26 pm

[QUOTE=PixelHero] It might be better to flip that around ArcadEd. In your example it would be the time since the previous attack that would determine what attack you could perform (rather than time since previous), and I believe he's actually trying to prevent canceling the punch.

I would invert the meaning of your punchtimer like so:

variable punchTimer = 0

every Tick | subtract DT from punchTimer

then actions are only allowed if the punchTimer = 0. You can even prevent changes in direction or other actions that would cancel the punch. In this way, different punch styles can set the punchTimer to different values, so you can have more time to recover from a running punch than a idle punch, for example.

'Course, I could have also misunderstood what he wanted to do, too.[/QUOTE]
no no
you got the point

thx man
B
13
S
3
G
1
Posts: 51
Reputation: 971


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests