Instance variable destroys two not one

Just started using Construct 2? Post your questions here

Post » Thu Jan 08, 2015 1:52 pm

Here is the capx.
@brunopalermo

@Kyatric
You do not have the required permissions to view the files attached to this post.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 1:56 pm

r2cvv wrote:
ramones wrote:What about the events that damage the enemy? Maybe you damage both enemies when you hit one. The event you showed would only destroy two enemies if they both have health <= 0.

@ramones Here is the code for the player attacks. Whether it is the first code or the second they will both be destroyed.

Right that will damage all enemies. You have to use:
Player: On collision with Family -> Family: Subtract from health
or
Player: On collision with Sprite -> Sprite: Subtract from health

Use either the Family or the Sprite in both the condition and action. You can't use the family in the condition and the sprite in the action or vice versa.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Jan 08, 2015 2:19 pm

Here...

error.png


Whenever the player collides with any member of the Enemy family you are damaging all FlyerEnemy and Shooter instances. :)

Use: Enemy subtract X from Health
You do not have the required permissions to view the files attached to this post.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
19
S
5
G
1
Posts: 530
Reputation: 2,727

Post » Thu Jan 08, 2015 3:45 pm

@brunopalermo Thanks! Your suloution helped me!
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 5:56 pm

One last thing... I noticed you wanted the enemies to take different amounts of damage. Instead, you could have the damage fixed and vary the enemy's HP.

Thus, instead of the bullet causing 2 to the Flyer and 8 to the Shooter, make the Flyer HP 4 times the Shooter's. You'll have the same effect.

Or you could have the damage taken as an Enemy variable. Whatever works for you.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
19
S
5
G
1
Posts: 530
Reputation: 2,727

Previous

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests