Hi!
I started to make a planet simulation game using Box2D.
For this all planets must have own gravity force, that I can "refresh" all steps.
I tryed to do this with ApplyForce function, but it didn't work.
I want to ask, that is the Box2D capable of handle all center of mass like a gravity center.
Thank you for all hint or advise!
Firstly, Box2D does not use Runge-Kutta, and secondly, it is also just an approximation,just a better one. Once you get to three bodies, gravity is chaotic, so no integration technique will be accurate forever.
Also, FWIW, Box2d uses symplectic Euler (which is like a leapfrog integrator, where velocity "lives" on the half-step during integration, which is a good thing) instead of standard Euler, and it has far better stability and reversibility properties, especially for simple 1 body force functions (reversibility implies some level of stability, since in a periodic system if we have reversibility we automatically get stability due to the fact that energy cannot consistently grow, with some caveats). So if you did that stationary orbit demo in Box2d, I would expect that you should get results similar to RK4.
Where RK4 really shines is when you have much stiffer N-body systems like massive spring assemblies, because it can tolerate sub-timestep natural frequencies. It's rather difficult to properly integrate another integrator like RK4 with Box2d because a lot of the constraint solving makes assumptions about the integrator, so you'd need to touch a lot of code. I'm not sure how results would be if you just ignored those other things and directly swapped the integrator, but one thing to keep in mind is that with RK4 it's no longer enough to merely apply forces, you have to provide callbacks to recompute them based on the current system state as well, so it's not just a simple swap.
I agree with BorisTheBrave, Box2d will not be accurate enough to indefinitely model the N-body interactions in our solar system, though I'm not sure how quickly it would break down. Depending on your purpose it might be good enough.