# Why does not work "Pick nearest"?

Get help using Construct 2

### » Fri Jun 30, 2017 10:32 am

The game is a bubble shooter. If the speed of the bullet (bubble) increases and when the bubbles collide, the condition "else" begins to work. Why is this happening and how to fix it? But if the speed is about 500, then the pick is triggered correctly.

capx example

B
7
S
2
Posts: 5
Reputation: 535

### » Fri Jun 30, 2017 2:05 pm

Should work if you bring that condition "animation frame = 1" in event 13 above the 'pick nearest'.

Currently you pick the nearest out of all points, then you check if it can be used. And it gets no second chance.

Should be: Pick all that can be used and from those (filter) pick the nearest.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Fri Jun 30, 2017 3:51 pm

Oh, thanks, this simple logical mistake cost me a lot of time
B
7
S
2
Posts: 5
Reputation: 535

### » Fri Jun 30, 2017 9:49 pm

Well. The mistake is that you see it as a 'logical mistake'. It is not. And is way more simple then that.

Lets read your event 12 as example. It states this.

On the moment that there is a collision happening between any Family member (containing the bubbles) and any instance of Bubble, trigger this condition, and make a picklist containing that Family member and that instance of Bubbles.

Keep in mind that, if you trigger a a collision check between X and Y, the mechanism that picks X will not include Y, and the mechanism that picks Y will not include X. Since you check between instances of the same object, the mechanism that picks X, starts with something holding X & Y (both collide, and they are instances of the same object). It is holding them in order of creation. So X is the one created before Y. Then it excludes Y, being the last one in that order. Or, X will always be the first created instance (when you trigger a collision check between instances of the same object)

So, in your case. Family will always be the first created instance in the list of colliding instances, that means that Bubble will always be the one that is shooting. (it is created last).

So the picklist made in that 'on collision' condition contains 1 Family member and 1 instance of Bubble and Bubble is always the shooting instance of the two.

Any following conditions, and sub conditions will start picking from that and only from that picklist.

So, then next condition picks from that (previous picked) picklist the Family member with stand = 1. Seems a bit weird, it will always be 1. But, you create the next bubble on its start position before the previous shooter bubble is gone from that start position. Hence they will also collide and trigger the 'on collision'. You prevent this with this construction of conditions. But that is not really elegant.

The next 2 conditions pick from the previous picked picklist the Bubbles with Shooter = 0 and Fly = 1. Since Bubble in the previous picklist is always the flying Bubble, this should not be needed. Dont know why they are in place. Did you need to fix another unexpected collision ? When you re-position the bubble on its endpoint maybe ? You do not use solids. So when the collision happens, they are overlapping. Take them apart and that will probably trigger the collision check again.

Now the actions in that event work ONLY and ONLY on the objects in the picklist.

So, mainly, most conditions make a picklist, the parent condition makes the parent picklist, all other following sub conditions start picking from that parent picklist. The actions work on the objects in the picklist.

But now that 'else'. Else is truly a logical condition. It will run when its parent condition(s) did not run. The parent condition will not run when it is UNTRUE. Untrue for pick conditions happen when the picklist is empty.

Hope you see the point of it all.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450