matching instances

Get help using Construct 2

Post » Sun Jan 20, 2013 8:18 pm

I have lots of instances of the same object and when 2 overlap and both have the same matching variable i want to destroy them. If the variables don't match i don't want anything to happen.

I've tried multiple different variations of this sort of thing

sprite overlap sprite
sub event - for each sprite
+ sprite variable = 1

destroy sprite

This works however it still destroys 1 sprite if it has the correct variable and the other doesn't. How do i check both instances during the overlap?

Thanks.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Sun Jan 20, 2013 9:00 pm

If you have one of the paid versions you can use "the family trick" to do this.
Just add the object to a family, and add a variable to both the object, and the family.
Then when you create the object set its variable, and its family variable.

For the collision event:
+>object variable= your value
-->object is overlapping family
--->family variable = your value, do stuff

@Ashley
Would it be possible to add something like is overlapping(at offset) other instance, and collision with other instance?
While using a family works, it still seems kind of hackish.newt2013-01-20 21:08:42
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Jan 21, 2013 6:22 pm

I'll try that, thanks for your help.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Mon Jan 21, 2013 7:08 pm

I'm afraid that method doesn't seem to have worked either, unless i haven't implemented it correctly, or i haven't explained clearly what i'm trying to do. I'm sure the fault lies with me.

This is what i'm trying to accomplish,

sprite.instance1 overlaps sprite.instance2, and sprite.instance1 variable=1, and sprite.instance2 variable=1, then destroy both instances.

if sprite instances have different variables then destroy neither.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231


Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, emoticon, MrWhizm, Skebab, Yahoo [Bot] and 18 guests