Question on families

Get help using Construct 2

Post » Sun Aug 25, 2013 1:24 pm

Hey hello!

I have a problem, I'm hoping you can help me solve.

I want to use families to have the player's damage apply equally to all objects, inside one particular family.

For example:

Family "Enemies" holds one object: "Enemy"

Player character does 10 damage per attack.

My logic:

If Family "Enemies" is on collision with Player_Fist:
    >
    >
    (Sub-event) For each Enemy:
        Subtract 10 from Enemy.HP

Ok fine, seems to work. But what if Family "Enemies" held, say, three objects:

Enemy_Light(100HP), Enemy_Medium(150HP) and Enemy_heavy(200HP).

Then what?

Thanks in advance fellow Constructors! I know I can always count on you!

B
7
S
2
Posts: 51
Reputation: 627

Post » Sun Aug 25, 2013 1:55 pm

See how events work. You don't need a sub-event or a for-each loop there, you can just write:

+ Enemies: on collision with Player_Fist
-> Enemy: subtract 10 from HP

This will work exactly the same, and is simpler. If there are multiple enemies, the event picks only the instances that met the condition, so it works like you expect.
Scirra Founder
B
399
S
236
G
89
Posts: 24,523
Reputation: 195,378

Post » Sun Aug 25, 2013 5:12 pm

Simple and effective! Cheers my friend.
B
7
S
2
Posts: 51
Reputation: 627


Return to How do I....?

Who is online

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