Question on families

0 favourites
  • 3 posts
  • 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!

    <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Simple and effective! Cheers my friend.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)