liabru / matter-attractors

an attractors plugin for matter.js
MIT License
148 stars 31 forks source link

Gravity Doesn't Seem to Increase As Distance Between Objects Decreases #12

Closed GreysonR closed 5 years ago

GreysonR commented 5 years ago

I'm making a game with matter.js where you can create your own solar system, but instead of elliptical orbits like you'd expect where the planets would get close to the star and then swing around it, the planets always keep their orbits completely centered around the star. Is there any way I can fix this? Note: I have tried to use the built-in Newtonian gravity, but it doesn't work at all with anything I've tried.

For reference: Elliptical Orbits Wrong

GreysonR commented 5 years ago

I got it to work, but instead of using MatterAttractors.Attractors.gravity, I had to copy and paste the gravity function inside the body. I have no idea why this worked and the other method didn't, though