Skip to content

Commit 74bf6e0

Browse files
committed
Fix circle collisions detection
1 parent 1cc984a commit 74bf6e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

js/modules/Physics.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export default class Physics {
4141
* @arg {Celestial} b
4242
* @returns {boolean}
4343
*/
44-
(a, b) => a.position.vectorTo(b.position).magnitude < a.size + b.size,
44+
(a, b) =>
45+
a.position.vectorTo(b.position).magnitude < (a.size + b.size) / 2,
4546
},
4647
};
4748
/**
@@ -134,8 +135,8 @@ export default class Physics {
134135
}
135136
/** Calculate the physics for objects in the scene and apply to model. */
136137
step() {
138+
this.updateCollisions();
137139
this.updateVelocities();
138140
this.updatePositions();
139-
this.updateCollisions();
140141
}
141142
}

0 commit comments

Comments
 (0)