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
151
S
75
G
20
Posts: 1,793
Reputation: 22,749

Post » Sun Jan 08, 2012 4:29 pm

Sounds like a bug. It should work as you described.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

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
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

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
151
S
75
G
20
Posts: 1,793
Reputation: 22,749


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests