How do I apply an action to all family members

Get help using Construct 2

Post » Tue Aug 21, 2012 6:23 am

Hi guys!
I'm starting to use families since my license upgrade :) and just realize that families are made for attach behaviors to all the members but not to apply the action to all of them at the same time but just for the member that triggered the event.

I understand that families were made that way. I've read http://www.scirra.com/manual/142/families and of course "Laser", on collision, has to destroy only the enemy family member that triggered the collision...

... but if I want to destroy all the members on the family "enemies" when any collision between laser and enemy happens?

Is there a way to do this without doing it one by one?

Similar to what I need is:

Family: "myFamily".
Content of "myFamily": 20 different sprites.
The 20 sprites behavior: Physics.

The sprites are moving randomly on the screen and when one hits another, I want to destroy all the "myFamily" members.

I tried:
"myFamily" -> on collision with "myFamily" -> "myFamily" destroy.

But this only destroy the collisioners.


Thanks for your time guys ;)
B
29
S
6
G
5
Posts: 148
Reputation: 5,084

Post » Tue Aug 21, 2012 6:30 am

Well, the simplest way I can think of is to make a new global variable (let's call it "Destroy") and set it to 1 on the collision. Then in a separate event, say "If Destroy = 1 -> myFamily destroy".

There might be another way, but this'll do the trick.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Aug 21, 2012 9:25 am

+ Laser: on collision with myFamily
   + System: Pick all myFamily -> myFamily: destroy.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Aug 21, 2012 9:32 am

Haha, yup... I figured there was something like that, but I've never had to use it before.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Aug 21, 2012 6:14 pm

@shinkan thank you! I knew that something like that had to exist.
Thank you very much :)

I will try it as soon as I get home.

@SullyTheStrange thank you for your time and suggestion too :)GamerGon2012-08-21 18:16:05
B
29
S
6
G
5
Posts: 148
Reputation: 5,084

Post » Sat Aug 25, 2012 3:50 am

I forgot to thank you @shinkan, it works for what I need to do :)GamerGon2012-08-25 03:50:36
B
29
S
6
G
5
Posts: 148
Reputation: 5,084


Return to How do I....?

Who is online

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