-
What do you want to achieve?
I want to make a a gravitational web that reacts to the parts’ gravity around it, somewhat like on this website.
-
What is the issue?
I can’t start making it, becuase I have no idea on how to start.
-
What solutions have you tried so far?
There aren’t any solutions so far. I’ve found some old forums but those were about gravitational forces between two objects, so that didn’t work out.
You can simply simulate the acceleration between each object and every object pulling on it, but there’s a problem. This is highly numerically unstable, orbits that should be stable will decay for precision reasons. The algorithms that solve this issue are extremely complex. To avoid doing those when you don’t actually need them, you’d need more info about the requirements you’re trying to achieve.
I don’t understand how what you want is different.
So what you’re saying is that this thing is very complicated, right? Then I might leave it, I’m not at that level yet.
By gravitational web I mean something like this, which shows the object’s mass (not sure what it shows). But now that I read your message again, they might be the same thing. But the thing I meant was that the post was about two parts (planet and moon) pulling eachother.
I recommend you do it anyway to see what the issues look like. The grid in the background just shows the gravity for all points around an object. You can calculate that, but the value only matters where it meets another movable object. For that reason most simulations also do not have tidal forces.
Yea, it sounds really complicated to me (based on my knowladge), so I might just leave it and try to imporve. Thanks for the replies tho.
The way I mentioned is pretty easy, in fact the assistant might generate the whole thing for you.
No, this is extremely easy. It’ll only be unstable if the simulation time step is too large, if you only want to practice scripting you don’t need to worry about this, it’ll work.
Here’s how you would do this:
For every object in space, calculate the forces exerted upon it by every other object that isn’t itself.
This is the gravity equation:
F = G * ((m_2 * m_1) / (r^2))
where:
F
is the force acting upon the object
m_1
is the mass of the body
m_2
is the mass of the other body pulling on it
r
is the distance between the two objects
G
is the gravitational constant, which can be any arbitrary number you want based on absolutely nothing, in real life this number is equal to 0.000000000066743 (metric units)
To convert force to acceleration just divide it by the mass of the object that the force is acting upon.
Went ahead and did that to see, this might work pretty well as an example:
gravity.rbxl (53.7 KB)