diff --git a/index.js b/index.js index e4c6249..5723768 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,10 @@ const MatterAttractors = { attractors = bodyA.plugin.attractors; if (attractors && attractors.length > 0) { - for (let j = i + 1; j < bodies.length; j += 1) { + for (let j = 0; j < bodies.length; j += 1) { + if (j === i) { + continue; + } let bodyB = bodies[j]; for (let k = 0; k < attractors.length; k += 1) { @@ -136,4 +139,4 @@ module.exports = MatterAttractors; * @param {Matter.Body} bodyA * @param {Matter.Body} bodyB * @returns {Vector|undefined} a force vector (optional) - */ \ No newline at end of file + */