On collision with a family member subtract a variable

1 favourites
  • 7 posts
From the Asset Store
Perfect Particles
$2 USD
80% off
Particles support animations, collisions, effects and etc.
  • Hi there, thanks for taking a look ... this is more of a 'wonder if i could'

    So I have a family called 'Enemies' and within that grouping there are 10 Objects, all Sprites and all of them have their own numeric instance variable called Damage.

    What I would like to happen is that if the player collides with a member of the Enemies family, it picks the object it has collided with and subtracts that object's Damage variable from a Global Variable.

    Apologies if this doesn't make sense ...

  • could be wrong, but I think you can simply do an on collision with family substract damage from global variable in this case

  • Yes you can do that, did you try it as described?

  • Thank you for responding and insanesnake

    Yes, and this is what happens for me ...

  • Assuming you have set up instance variables for each individual object called Damage, this is why Families are powerful because you have a 'Family Instance variable'. That is what you're referencing there but you haven't used it. Create a family instance variable called Damage then every enemy will have it (you don't need to add the variable individually to each member of Enemies). You can only reference Enemies.Damage if it's setup for family, otherwise you need to reference individual enemies, EnemyA.Damage, EnemyB.Damage. Better to group in a family, which is what you're trying to do I can see but didn't quite get there yet

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much! Brilliantly explained!

  • No problem, good luck and feel free to post back here if you have any problem with using families.

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