Strange phenomenon in event handler

Could somebody please explain this phenomenon for me?
I produced 5 snow flakes and tried to delete it when each flake touched ground. But I found when No.1 flake touches ground No.2 flake is deleted. And when No.3 flakes touches ground No.4 flake is deleted. And finally for the last one, No. 5 flake touches ground, No.5 flake is deleted. This phenomenon is changed a little bit according to the time interval of producing flakes.
Actually I can manage to correct this phenomenon as I want to happen, so I don’t need the solution.
I just like to get clear image why it is supposed to happen so that I don’t repeat the same mistake for another case.

Many thanks,

Hi, that happens because you delete a flake stored in the “particle” variable. But when you create a next flake, the value of that variable changes and stores the second flake.
The easiest way of solving it is to move collision CoBlock to the function. So the variable in the delete CoBlock will be local and will not be overwritten:

Is it good to understand that the two objects used in the [ Collision handler] and [delete] statement are not the same thing?
I thought and expected that when the Collision handler is reserved by a certain (particle) , all statements inside handler also use the same (particle) .
It is a bit vague for me but I will keep it mind that principle.

image

Thanks Nikolay,

1 Like