Comments and answers for "My orbits don't look like KSP"
http://answers.unity.com/questions/1705535/my-orbits-dont-look-like-ksp.html
The latest comments and answers for the question "My orbits don't look like KSP"Comment by Antilight on Antilight's answer
http://answers.unity.com/comments/1705576/view.html
Thank you for your help Bunny! It's clear now that I need to rethink my gravitational forces.
To clear up the "surface" thing: "surfaceGravity" is in Earth G and "surfaceRadius" is the radius from the planets center to its surface because I start applying gravity at the surface and scale it down to "sOI" (sphere of influence).
I'm not trying to create an accurate 1:1 solar system. In fact, at the moment I'm thinking I want my largest planet to be just 1 km in diameter so that should give you an idea of how realistic I want the sim to be. But I do want my orbits to look accurate to the naked eye. I mean if you were to imagine a universe where planets could be that small and still have that much gravity. But if you watched the video (I updated it to make it more clear and skip to the end to see the orbit paths) you would see that my cubes orbit in an oval shape with the planet being in the middle. I know it is possible to have an orbit that passes just above the airless planet on one side (periapsis) and reaches thousands of km on the other side (apoapsis). What I'm wanting is to create that effect.
I'll use what you taught me and do some research hopefully I'll figure something out. Thanks again, especially for clearing up the mass part of the equation. I didn't understand why I needed the mass.Sat, 07 Mar 2020 15:05:16 GMTAntilightAnswer by Bunny83
http://answers.unity.com/answers/1705561/view.html
Well, there are several things you have to clear up first. First of all do not base your knowledge of orbits on other games. Second your whole equation doesn't seem to make much sense and does not look like it resembles Newtonian gravity, at all. All your "surface" references doesn't make much sense and you scale your gravity linearly by the distance. Actual gravity scales with the quare of the distance.
<br>
The actual gravitational force is
F = G * m1 * m2 / dist²
However the resulting acceleration for a body is `a = F / m`. That's why the attacted mass is irrelevant for the acceleration. If you plugin the values
F_body = G * m_center * m_body / dist²
a_body = F_body / m_body
a_body = G * m_center * m_body / (dist² * m_body) //-->
a_body = G * m_center / dist²
As you can see the mass of the body doesn't matter as it cancels out. In the case of an object close to earth, m_center is the mass of the earth and "dist" is the distance from the **earth center**. On the surface that's about 6000 km and gives us our famous acceleration of 9.81 m/s². However further out that value is significantly less. Keep in mind that the acceleration scales by the square of the distance from the center. So at double the radius it will be only a quater.
<br>
Yes, on the surface or very close to the surface the acceleration doesn't really change much. Most things we care about on earth happens within say a 12km range above ground If we take the average earth radius (6371 km) and plug it into the formula we get 9.8196 m/s². If we add 12km we get an acceleration of about 9.7827 m/s². So only a tiny difference (0.037m/s² less)
<br>
Of course on a planetary scale distances get much larger therefore you really should use the distance squared properly.
<br>
However the fact that you see an eliptical orbit that is in itself rotating around the sun / center is just a matter of fact that you're doing a time discrete integration simulation. This will never give you an accurate result. The real world does not run in discrete time steps but performs actual continous integration. Increasing the simulation steps per second would help to mitigate the issue slightly but your orbit will always drift when doing this. Many orbit simulations work with the derived orbit equations where you define your orbit based on the initial condition / changes and if no external force is applied we just follow our calculated orbit.
<br>
While calculating such an orbit is not rocket science, it is actually part of it and naturally not that easy ^^. Here are a few sources which might help you out
- [https://en.wikipedia.org/wiki/Orbit][1]
- [https://en.wikipedia.org/wiki/Kepler_orbit][2]
- [https://en.wikipedia.org/wiki/Orbital_elements#Keplerian][3]
The real question is what do you want this orbit for and what level of accuracy do you aim for?- Note that even when using the right forumlas due to floating point errors a simulation won't be "100% correct". When it comes to actual orbits there are so many things that has to be accounted for. While still in the athmosphere there's drag / air resistance. All objects in a orbital system rotate around the [center of mass][4], even the largest "center" object. If more objects are involved this gets infinitely complex. Those changes are tiny but still have a small effect, especially over time. So again it highly depends on what your goals are.
<br>
Games in general do not really need to be physical accurate. In fact PhysX (which is used by the Unity engine) is in itself not physically correct. It's just a simulation that is fast and very close to common needs where the errors are usually small enough so you won't notice. For example PhysX does not perserve the angular momentum as it true in actual physics. Instead it will just preserve the angular velocity. This makes the simulation much simpler but certain things are impossible to simulate with such a system. Like the [tumbling effect][5] mentioned here in the middle bottom figure. Because this never happens in Unity we can not use this physics system to simulate things like a [kickflip][6] of a skateboard properly without a massive amount of workarounds. Most physics systems for games are build to give you a good approximation and to be efficient.
[1]: https://en.wikipedia.org/wiki/Orbit
[2]: https://en.wikipedia.org/wiki/Kepler_orbit
[3]: https://en.wikipedia.org/wiki/Orbital_elements#Keplerian
[4]: https://en.wikipedia.org/wiki/File:Orbit2.gif
[5]: https://www.youtube.com/watch?v=fZYfX9VvN8M&t=80s
[6]: https://www.youtube.com/watch?v=wfCgCXvw50ASat, 07 Mar 2020 14:08:11 GMTBunny83