- Wed 12 Jul 2017, 16:14
The 1 and 3 methods should work, the problem is the way GD handles instances, you can't just do Box.Distance(Box) because GD doesn't know which Box respect to which Box check the distance, as the Box instances taken into account for the event stand in a list the result is unpredictable I think, maybe it will check every Box object distance to every Box except iself, not sure...
What you have to do is add a "token", a placeholder for the first Box: Add a new object, for example a sprite (if you'll check position any kind of object can do the trick) and set it position = position of the central Box.
Now instead deleting the Boxes at X distance from the central Box, you have to delete the Boxes at X distance from the Placeholder. The Boxes to delete and the Placeholder to check distances are different objects so GD will have no problem
Some things to note:
* Distance functions measure from the objects center, so you have to place the Placeholder in a way that the Placeholder Centre and Box Centre points overlap (for example put the Origin point of the Placeholder at the Centre point and create the Placeholder at the Centre point of the Box).
* If you use the distance method you should use a little tolerance factor too (a range), because float precision. You will have to add a condition per possible distance to the central box (diagonal range 1 (first radius), diagonal range 2 (second radius), etc.).
* The best coding way (I think) to do what you want, the natural one, is to use angles, I think there is no condition to check angles between objects (there is one to check angle of movement between objects I think, sorry, no GD in this PC, checking the sources), so you'll have to test the distances manually, and add a little tolerance angle too. If you know some trigonometry, the dot/cross products can make the things easier
* Did you try to make a big cross sprite with a cross collision mask, and delete the Boxes colliding with the cross? That would be super easy!
I should be studying now :/