player invinciblity

Get help using Construct 2

Post » Mon Nov 04, 2013 6:57 am



I am having an issue with my change states for my player when he gets hit.

Right now when he collides with something it randomly takes off hearts..it could be one or all 3...I am not sure how to make my player invincible for a small time period after collision with the enemy....

B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Nov 04, 2013 7:04 am

Try a switch case.
Or make one event "every 3 seconds" and ask for the playerHealth in a Subevent.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Nov 04, 2013 7:13 am

http://www.dwbailey.com/images/healthevent.capx

not sure what you mean by one event for the every 3 seconds..here is the capx.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Nov 04, 2013 8:22 am

if you have flash effect i have made a rather simple off on switch for invincibility

put all the monsters in a group

or put your collisions with the monsters in a group.

when your character is flashing turn off the group that causes you to take damage.

If character is flashing -->> Turn off group Monster is hitting me

and

Character on Flash end -->> Turn on group Monster is hitting me

basically as long as your flashing you cannot take damage or get hit!

give it a try
B
5
S
1
Posts: 88
Reputation: 653

Post » Mon Nov 04, 2013 1:15 pm

Move your "subtract 1 from health" action down to the section that has "every 3 seconds"

Right now its happening "every tick" so that's why its random why sometimes its taking 1 heart and sometimes more.

B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Mon Nov 04, 2013 6:08 pm



i tried it this way and couldnt get it to work..

Hey justifun....you said move subtract 1 from health down to where it has every 3 seconds.....should i put that at each state change.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Nov 04, 2013 6:38 pm

Justifun means what i said before. Now every tick when the player is in collision with an enemy, it subtracts 1. You could add the every 3 seconds condition to the "on collision with enemy" event.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Nov 04, 2013 7:43 pm

Is there anyway someone from here can open that capx and get it to work so I can see exactly what to do...right now everything I tried just gets horrible results....also I am not sure why the isinvisible var doesnt do the trick?
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Nov 04, 2013 7:44 pm

to get the every x sec to work...does it need an every tick in the beginning?
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Mon Nov 04, 2013 8:30 pm

Simply add the "Idle is not flashing" condition to the collision check event.
You don't need the global variable "IsFlashing" at all to achieve this.
B
11
S
3
Posts: 224
Reputation: 2,028

Next

Return to How do I....?

Who is online

Users browsing this forum: charliesan763 and 13 guests