Bond with the nearest ball.

https://codepen.io/-bloop-/pen/jOeJzqr in this given codepen, u can see there's 30 balls each with their respective x and y velocity. the intention of the code was to make so that each ball forms a bond with it's nearest ball. But apart from the first ball, all of the balls don't actually create a bond with it's nearest one unless a ball is very very close to it. Does anyone how why it happens or how I can tackle this? I've added descriptive comments in my code so it'll be easier to understand what each codeblock does. tnx ❤️
2 Replies
glutonium
glutoniumOP2y ago
all the balls were supposed to behave like this
glutonium
glutoniumOP2y ago
nvm..i found the problem.. the problem was, the variable closestDis doesn't revert back to it's original value with was 9999, so had to put it in the outer loop so it works the same for all the balls
Want results from more Discord servers?
Add your server