Refering to this thread, are there any updates for that?
It may be outdated, but a good solution. :-)
How to get this work with multiple "Black Holes" ?
Thank you very much ;-)
For each black hole apply a force to the sprites toward blackhole.x,blackhole.y and the amount of force would be
K/distance(sprite.x,sprite.y,blackhole.x,blackhole.y)^2.
K is just some number. If the black hole is too weak just use a bigger number.
Thats a very good idea, and it works :-)
I would like to arrange such physics beside moving holes (planets, a sun etc) with different sizes (mass)
The problem I see is the selection of "all other objects" of its kind.
U got a solution for that?
Develop games in your browser. Powerful, performant & highly capable.
Roughly you’d do this to apply gravity between two objects a and b. You’ll have to tune it though. Adjust the masses of the objects, and the g variable.
Var g=10000 Var ang=0 Var force=0 Every tick — set ang to angle(a.x,a.y,b.x,b.y) — set force to g*a.mass*b.mass/distance(a.x,a.y,b.x,b.y)^2 — a: apply force (force*cos(ang), force*sin(ang)) — b: apply force (-force*cos(ang), -force*sin(ang))
That handles the gravity between a pair of objects. You’d just have to do that between every pair.
If you search my posts I’ve made an example or two in the past if that helps.
I was going to attempt to make an example but I found a lot of previous tests that may be helpful. There are probably more but my naming convention is inconsistent. Some use physics for the motion, and some do the motion with math in events. I skimmed over them briefly but maybe a third of them have the forces between every pair of objects.
dropbox.com/s/8bimqsdnysh5bov/orbital_simple.capx
dropbox.com/s/eldpa0s7zvfr333/orbit2.capx
dropbox.com/s/tk76c6cmc4vlocd/orbit.capx
dropbox.com/s/5dpb882vdi03d00/orbit.capx
dropbox.com/s/gle6gz7lbo18cq7/orbit_physics.capx
dropbox.com/s/9zx2ivqzli2ewbx/orbital.capx