Picking between instances on overlap

Get help using Construct 2

Post » Sun Jan 08, 2012 10:28 am

I'm not sure if this is a bug, or if my logic is flawed somewhere in this event. When this pink sprite overlaps a carrot, I want it to only pick 1 of them. So my event reads: Sprite Overlaps Carrot, pick 1 of them at random, however it doesn't seem to care about any picking condition that happens after the overlap and applies the actions to all instances that are being overlapped anyway.



A note: This is a subevent of a button press thing, so it can only happen once.

B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Sun Jan 08, 2012 4:29 pm

Sounds like a bug. It should work as you described.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jan 08, 2012 10:12 pm

"Is overlapping" has a built-in "for each". It was the same in CC, although "overlapping at offset" just was a filter.

If "Is overlapping" was just a filter your conditions would look like this:

p_det | carrying=0
p_pickup | is overlapping o_carrot
for each o_carrot
System | pick a random o_carrot instance
B
79
S
24
G
54
Posts: 4,755
Reputation: 40,773

Post » Sun Jan 08, 2012 11:25 pm

Oh wow that's interesting, thanks Rojo! So to make it easier for me to understand, I'm going to presume that the "for each" condition is always there after an overlap but just invisible.

Now that I understand that, it was a simple fix in this case. I replaced the "pick random" condition with a check to see if 'pickingup' variable equaled 0, so that the event was only occurring once.

Fantastic, thanks for you help.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190


Return to How do I....?

Who is online

Users browsing this forum: dadanwsd and 20 guests