Indestructible for a while

Get help using Construct 2

Post » Sun Sep 29, 2013 12:24 am

Hi there,
I want to make my hero invulnerable for a sec after he colided with an oponent. Unfortunately switching off colisions makes him fall from platforms:/. Is there an easy way to make this happen?
Thanks!
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Sun Sep 29, 2013 2:47 am

dirty

If playa touches enemy
if "took hit" = 0

takes X from health
set animation to "taken hit" (can be flash)
Set "took hit"(variable) to 1


playa on animation "taken hit" (could be flash stop) stop
set "took hit" to 0

Syntax is not correct, i am very drunkWhiteX2013-09-29 02:49:52
B
9
S
2
Posts: 35
Reputation: 668

Post » Sun Sep 29, 2013 3:33 am

https://www.scirra.com/manual/128/sub-events
Dude
It's in the manual
B
9
S
3
G
1
Posts: 191
Reputation: 1,725

Post » Sun Sep 29, 2013 5:02 am

In your event that causes damage to the player, put in a sub event that checks to see if they are currently allowed to take damange. Make a variable called something like playerInvuln and when it is true, do not do damage to the player. When the player gets hit, set playerInvuln to true. Or you could put the event that does the damage into a group and just disable the group whenever damage is done, put on a timer, and then re-enable the group once your preferred amount of time has passed... take your pick...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Sun Sep 29, 2013 12:20 pm

Thanks guys, its working. :) i had it set like this: on collision, take 1 health and add 1 to invulnerability. Unfortunately, it hasn't worked because it added 1 to invul. before it took the health. I had to set a very shor timer between.
B
8
S
4
G
1
Posts: 191
Reputation: 1,873


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 17 guests