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

Get help using Construct 2

» Fri Dec 18, 2015 1:26 pm

I have a family called WORM.

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 .
B
30
S
11
G
3
Posts: 667
Reputation: 4,974

» Fri Dec 18, 2015 1:37 pm

I'm not sure I understand..
Are there more worms than one?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Fri Dec 18, 2015 1:47 pm

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.
B
30
S
11
G
3
Posts: 667
Reputation: 4,974

» Fri Dec 18, 2015 1:55 pm

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.
B
49
S
20
G
89
Posts: 2,341
Reputation: 52,693

» Fri Dec 18, 2015 2:05 pm

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? ¿?
B
30
S
11
G
3
Posts: 667
Reputation: 4,974

» Fri Dec 18, 2015 2:08 pm

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.
B
49
S
20
G
89
Posts: 2,341
Reputation: 52,693

» Fri Dec 18, 2015 2:16 pm

plinkie wrote: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.
B
30
S
11
G
3
Posts: 667
Reputation: 4,974

» Fri Dec 18, 2015 2:28 pm

I've done this before using containers, every tick > if bodypart1(health=0) and bodypart2(health=0) > destroy container(worm)
B
49
S
20
G
89
Posts: 2,341
Reputation: 52,693

» Fri Dec 18, 2015 2:30 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Fri Dec 18, 2015 2:33 pm

LittleStain wrote: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
B
30
S
11
G
3
Posts: 667
Reputation: 4,974