Hello, I’m trying to understand what is the right way to implement a system of attraction-repulsion between two spheres by using cannonjs.
I should basically be able to determine two forces which regulate the following rules:
- if the attractive force = repulsive force: the two spheres stay in equilibrium and don’t move.
- if the attractive force > repulsive force: the spheres collapse into each other.
- if the attractive force < repulsive force: the spheres get away from each other.
I saw this thread but I didn’t understand how the force is implemented in this scenario.
EDIT: I have used Spring but it only works with two spheres. You can download my demo: cannonjs-attraction-repulsion.zip (1.4 MB)
Is there another way?