How do I check if all instances of a family match the same?

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I have a family called WORM.

    Worm is made by two object. Head and body.

    Each one have an instace called Life=2

    How i sai that when the family worm life is 0 = Destroy

    ¿? I'm stuck all the day, and sure will be a silly thing, but i search on forums and the documentation and i can't find it :S and sure is commented several times .

  • I'm not sure I understand..

    Are there more worms than one?

  • I have a familly called worm that have an instance variable called "life" that is set at 2. Actually i only have a one worm. And a worm is based on: 1 head and 4 body parts.

    So the idea is: when head and body parts have life=0 -> then do the action.

    This have to be a silly thing but i can't find the solution. I tried with "Pick all instances + Enemy.life=0 -> do action" etc... but nothing all the expresion and things fails :S , in the moment one of the objects/parts have life 0 is destroyed instead wait until all the parts of the worm is=0.

  • Sounds like you need to set up a 'Family instance variable' for life and check against it. Then you check if Family.life=0 > do this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Already the family have life=0. And the parts are in the family. All the morning lost for this thing XD

    If i say

    (Family) Enemies | Life = 0 -> Destroy

    He not get all, he only get that when one of the parts get life=0 do the action.

    So, how check if all the objects in the family match the same criteria? Or a group of objects or something instead only one? ¿?

  • I think you're using families wrong here, unless you're planning to have more creature types in future? You can set up the worm as a 'container', this then means that when one part is destroyed, they will all be destroyed. They're useful for this. Families are for affecting a family of objects at once i.e. a number of different kinds of worms rather than parts of a single object. If they're a container then this logic might work because if you pick a part of the worm to check against then it will pick every other part of the worm as well.

  • I think you're using families wrong here, unless you're planning to have more creature types in future? You can set up the worm as a 'container', this then means that when one part is destroyed, they will all be destroyed. They're useful for this. Families are for affecting a family of objects at once i.e. a number of different kinds of worms rather than parts of a single object. If they're a container then this logic might work because if you pick a part of the worm to check against then it will pick every other part of the worm as well.

    The problem is that i only want to destroy the enemy when all the parts have life=0 .

    I mean, i can hit until the head of the worm get life=0 but only when all the parts of the worm have life=0, this means head and the 4 body parts be destroyed.

    I can do that when the head or the body is life=0 destroy, but the problem is how destroy the entire worm only when all the parts are life=0.

    Which expresion i have to use in Construct2 to compare a serie/group of instance objects that when match some criteria do X action?

    I mean, i also tried to use expresions without family only direct to the object, body and head=0 then do action with the same result.

  • I've done this before using containers, every tick > if bodypart1(health=0) and bodypart2(health=0) > destroy container(worm)

  • I guess you could work with the pickedcount expression..

    Than the event would become something like:

    family compare variable = 0

    System compare two values: family.pickedcount = 5

    family destroy

  • I guess you could work with the pickedcount expression..

    Than the event would become something like:

    family compare variable = 0

    System compare two values: family.pickedcount = 5

    > family destroy

    Worked Perfect! A lot of thanks!

    Can you explain a bit? I not understand very well what is really doing this condition

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