How do I make my character invincible for a while

Just started using Construct 2? Post your questions here

Post » Mon Apr 03, 2017 7:32 pm

Hi guys, i started using Construct 2 this year, and i need some help!

I'm trying to make my character immune to damage for a while ( like when you pick up the mario star)
but it doesn't work :(

I have tried disabling the collision for a short period of time, but my character life still drops when a bullet hits him

How can i make my character invincible for a while??Like, his life wont drop after picking up a specific item, for a short period of time (like 4 seconds of invincibility)

Thanks for the attention, sorry for my bad english :/
B
5
S
1
Posts: 3
Reputation: 331

Post » Mon Apr 03, 2017 8:04 pm

Create a variable used to check if the player is invincible, and add an extra condition for any event that damages the player (save for things you want to invincibility to not ignore, like bottomless pits) that checks if the variable = 0, so if it's 1, the event will not run

Just so that animations and projectiles do not bug up, you may want to wholly include the damage-subtraction in a sub-event by itself under any source where it occurs in your event sheet.

Edit: you can use the timer behavior to run the duration of the invincibility and with:
>On timer "invincibilitytime"
>>Set invincibility-variable = 0


Keep mind that with the way timers work, the "on timer" will trigger when the timer runs out, just so you know how it properly works to understand how to utilize it correctly.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
50
S
24
G
30
Posts: 519
Reputation: 19,563

Post » Wed Apr 05, 2017 5:05 pm

@LaDestitute, i am sorry to waste your time, but i tried the way you explained but it didn't work. Can you be a little more specific on the steps that i have to do to make it work? If you want i can attach my project. Im new to Construct 2 and i don't understand exactly what do i have to do :(
B
5
S
1
Posts: 3
Reputation: 331

Post » Wed Apr 05, 2017 5:13 pm

xlrluccas wrote:Hi guys, i started using Construct 2 this year, and i need some help!

I'm trying to make my character immune to damage for a while ( like when you pick up the mario star)
but it doesn't work :(

I have tried disabling the collision for a short period of time, but my character life still drops when a bullet hits him

How can i make my character invincible for a while??Like, his life wont drop after picking up a specific item, for a short period of time (like 4 seconds of invincibility)

Thanks for the attention, sorry for my bad english :/


To do this you need to create a variable called invincible and on your events where it will decide wether the player has been hit add a sub event saying if invincible = 0 subtract 1 from lives and when the player equips the invincible power up that lasts for lets say 15 seconds add to the event sheet player on collision with invinciblepowerupobject add 1 to invincible set object invinciblepowerupobject invisible wait 15 secs set invincible to 0 :D
Image
B
24
S
13
G
11
Posts: 277
Reputation: 8,685

Post » Wed Apr 05, 2017 9:58 pm

Maybe you should read my example a bit more clearly and/or reference the manual for Construct 2 if you're not sure how certain behaviors or plugins work.
But, I've whipped this up to help you understand more clearly how to do this:
Image
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
50
S
24
G
30
Posts: 519
Reputation: 19,563

Post » Sun Apr 09, 2017 3:05 am

Thanks everyone, this was really helpful, finally i got it :D Thanks again for being patient with me!
B
5
S
1
Posts: 3
Reputation: 331


Return to Beginner's Questions

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests