How do I Make An Enemy Sprite Inactive Upon Defeat?

Get help using Construct 2

Post » Fri Jan 01, 2016 9:15 am

Hello Wonderful People!
I am new to Construct 2. I am making an 8-bit Platform game.
When I defeat an enemy sprite, I don't want it destroyed-- I want it to run off screen in a fit of tears. I figured out the running off screen part, but unfortunately if it collides with my player on the way out my player still takes damage. Is there a way to make the enemy sprite inactive, or un-collidible, upon defeat? As in, my player sprite can no longer interact with it?
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Fri Jan 01, 2016 9:24 am

Well, you just have to disable the part which makes the ennemy affect the player's health. I presume it's like "on collision with player" => player health = player.health - 1 or something. You can make a boolean variable "alive" initialised on true, and when this variable is false (after the ennemy's deafeat), then the ennemy doesn't affect the health anymore. For example :

[event]
Ennemy : On collision with Player
variable alive = true
[action]
playerHealth = playerHealth - 1

[event]
Ennemy : On collision with Player
variable alive = false
[action]
playerHealth = playerHealth

It's an idea, I didn't tested it, but that's how I'll try it.
B
16
S
4
Posts: 86
Reputation: 1,525

Post » Fri Jan 01, 2016 9:36 am

LeuNoeleeste wrote:Well, you just have to disable the part which makes the ennemy affect the player's health. I presume it's like "on collision with player" => player health = player.health - 1 or something. You can make a boolean variable "alive" initialised on true, and when this variable is false (after the ennemy's deafeat), then the ennemy doesn't affect the health anymore. For example :

[event]
Ennemy : On collision with Player
variable alive = true
[action]
playerHealth = playerHealth - 1

[event]
Ennemy : On collision with Player
variable alive = false
[action]
playerHealth = playerHealth

It's an idea, I didn't tested it, but that's how I'll try it.


2nd Event and Action would be pointless here. You are already testing against 'alive' variable in the first Event and the Playerhealth is only decreased if 'alive' is true - no need to test for false.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,486
Reputation: 59,758

Post » Fri Jan 01, 2016 11:04 am

Indeed, the first event should do the job. Thanks for this correction ;)
B
16
S
4
Posts: 86
Reputation: 1,525

Post » Fri Jan 01, 2016 5:14 pm

Got it! Thanks!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230


Return to How do I....?

Who is online

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