Check family to destroy object problem

Get help using Construct 2

Post » Sun Apr 07, 2013 3:54 am

Hello,

I would like to ask if this is common and right or a bug:

I'm checking a family overlapping an object:

- Family Bullets is overlapping Player: Destroy bullet;

and it's destroying all the bullets on the screen.

But I supposed to check a family and destroy the object would give me the able to check any type of bullet and only destroy that I told him.

So, going ahead with this mentality, I can make bullets that can pass through the player and others being destroyed on contact.

But by the other side, I could check the family and make to destroy the family, but that check didn't encapsulated the event only for the specific object meeting the conditions?
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Sun Apr 07, 2013 4:26 am

I think its right Telles,

Since you test the family, the family object is picked but then you give the command to destroy the 'general' bullet object without specifically choosing one, so it picks all of them.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sun Apr 07, 2013 4:40 am

@GenkiGenga

But so, it's the same of destroy the family, right?

It's not better to destroy only the instance checked, instead of the whole family on the screen?

And give the possibility to destroy the family by making it destroy the family?

Just brainstorming.
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Sun Apr 07, 2013 5:35 am

@TELLES0808

Im not sure I understand what you mean (my apologies if that is the case).

If you destroy the 'bullet family object' instead of the 'general bullet object' then only that 1 should be destroyed since it is picked in the event.



GenkiGenga2013-04-07 05:36:34
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sun Apr 07, 2013 6:09 am

[QUOTE=TELLES0808] Hello,

I would like to ask if this is common and right or a bug:

I'm checking a family overlapping an object:

- Family Bullets is overlapping Player: Destroy bullet;

and it's destroying all the bullets on the screen.

But I supposed to check a family and destroy the object would give me the able to check any type of bullet and only destroy that I told him.

So, going ahead with this mentality, I can make bullets that can pass through the player and others being destroyed on contact.

But by the other side, I could check the family and make to destroy the family, but that check didn't encapsulated the event only for the specific object meeting the conditions?[/QUOTE]

When you use families for collision check to destroy a general bullet then its going to assume if any sprite object in your "family" collides with player, then only the general bullet is destroyed. If your general bullet is in the family as well then it would be destroyed too.

Its gonna depend moreso on what your wanting to achieve. You could normally check for the instance of an object, if that same particular object is placed on the screen more then once, maybe then you would check the instances of the object and destroy the one you want to destroy. Now if you have all the general bullets in the family and you want them all to be destroyed, then family would be the easiest way since there basically grouped together as one sprite type.

But if there's a specific bullet you want to be destroyed, and you want the others to be in the screen, then go for the instance check instead because then you could target which bullets be destroyed, and which bullets be on screen.

I'm still a bit fuzzy on what I had just readretrodude2013-04-07 06:10:47
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Sun Apr 07, 2013 7:04 am

If you check for collisions within family, you should also set the destroy event to the family, not individual bullet object.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Apr 07, 2013 1:34 pm

[QUOTE=GenkiGenga] @TELLES0808

Im not sure I understand what you mean (my apologies if that is the case).

If you destroy the 'bullet family object' instead of the 'general bullet object' then only that 1 should be destroyed since it is picked in the event.
[/QUOTE]

Thank you, so, if you check a family, and if it meet the requirement, and I destroy the family inside the event, it will work only for the family object who is meeting the requirement?

I was thinking exactly the inverse, but this way make sense too.

Later I post here the two procedures and their real results with a sample file.

[QUOTE=retrodude]

When you use families for collision check to destroy a general bullet then its going to assume if any sprite object in your "family" collides with player, then only the general bullet is destroyed. If your general bullet is in the family as well then it would be destroyed too.

Its gonna depend moreso on what your wanting to achieve. You could normally check for the instance of an object, if that same particular object is placed on the screen more then once, maybe then you would check the instances of the object and destroy the one you want to destroy. Now if you have all the general bullets in the family and you want them all to be destroyed, then family would be the easiest way since there basically grouped together as one sprite type.

But if there's a specific bullet you want to be destroyed, and you want the others to be in the screen, then go for the instance check instead because then you could target which bullets be destroyed, and which bullets be on screen.

I'm still a bit fuzzy on what I had just read[/QUOTE]

That's the point, if I assume to check any bullet of the family is on collision, but destroy only the specific collided bullet, I'll need to check all the individual bullets again?

[QUOTE=vee41] If you check for collisions within family, you should also set the destroy event to the family, not individual bullet object.[/QUOTE]

If this is the case, family is only about the entire group and don't have use for their individual objects inside the family?
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Mon Apr 08, 2013 3:20 am

[QUOTE=TELLES0808]


Thank you, so, if you check a family, and if it meet the requirement, and I destroy the family inside the event, it will work only for the family object who is meeting the requirement?

I was thinking exactly the inverse, but this way make sense too.

[/QUOTE]

No worries Telles.

Exactly, I can see what you mean too since the bullet is technically part of the family anyway you would think that it was picked in the same way but it isnt.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605


Return to How do I....?

Who is online

Users browsing this forum: spacedoubt and 2 guests