Comments and answers for "Gravity simulation not accurate. Can't understand why"
http://answers.unity.com/questions/1543946/gravity-simulation-not-accurate.html
The latest comments and answers for the question "Gravity simulation not accurate. Can't understand why"Comment by FredOld on FredOld's comment
http://answers.unity.com/comments/1544274/view.html
Okay thank you. Though I am now super confused. I had it working accurately with what I said, so could you please explain only the scaling part for me? It would be really helpful, because I now have a complete mental block around this whole thing and can't get my head around what you mean.Mon, 20 Aug 2018 14:32:26 GMTFredOldComment by Bunny83 on Bunny83's answer
http://answers.unity.com/comments/1544260/view.html
Actually you argued the wrong way ^^. What you did no scale is "G". G tells you how much force you get for a given mass and a given distance squared. It actually links meters with kg. However not in a 1:1 ratio.
G is `m^3 * kg^-1 * s^-2`. Since you scaled mass and distance both by your scale factor you need scale G by your scale factor squared. btw: You need scale mass only once by your scale factor.
<br>
It would be much easier when you simply go the other way round. Just work with the original values and just scale the input and output accordingly. So multiply your worldspace distance by your scalefactor, do the math and scale down the end result by your scale factor. Since we deal with floating point numbers and only multiplication / division the number of significant digits doesn't really change so precision is not an issue.
<br>
Btw: Why do you convert the double value to string and parse the float from that string again? You can simply cast the double to float. This is much more performant, doesn't create any garbage and is much safer.
<br>
Another optimisation would be to not use "magnitude" and Pow but just use sqrMagnitude. You essentially calculate the square root and then square it again.
<br>
Finally keep in mind that a simulation like that is only stable for a short time due to floating point precisionMon, 20 Aug 2018 13:34:25 GMTBunny83Answer by FredOld
http://answers.unity.com/answers/1544174/view.html
I have solved the issue. It turned out to be rather simple: I had scaled all the distances down by 100000, so 1 unit was 100000 meters and I had adjusted the mass by the same proportion to make up for that, as I wrote in my question. However, the force appeared to be out of proportion despite my rigorous examination of all the scaling I has done. And finally I found of course that I have to divide the force magnitude by 100000 as well, because 1 N = 1 kg⋅m⋅s^−2 So if I have made 1 unity meter into 100000 real meters, I also have to apply this scaling here.
Thanks for your help @JVene !Mon, 20 Aug 2018 09:32:05 GMTFredOldComment by FredOld on FredOld's comment
http://answers.unity.com/comments/1543962/view.html
Thank you for your answer and please take your time. You seem to understand the problem, for this I am fortunate, as I am running out of ideas.
Referring to what you say; I have tried scaling time in past experiments and attempts to obtain accurate results. For instance, I tried a similar setup but it was with the earth and moon, the orbit shape was accurate but it was too fast, the orbital period was approx. 2650 seconds as opposed to 2332800 seconds, which is what it should be. This problem was easily solved by scaling time accordingly, but that leaves much room for inaccuracy, which is precisely what I don't want. It also felt like a temporary patch, but not something to solve this problem once and for all.
If you want I can attach the whole script and screenshots of the components. I don't know if this would be any help to you.Sun, 19 Aug 2018 17:40:53 GMTFredOldComment by JVene
http://answers.unity.com/comments/1543955/view.html
I've not taken time yet to study more about your inquiry, but what strikes me first is to ask about time. Have you scaled time?
----------
In a reverse scenario, many students of Unity try their first stack of blocks with unit blocks (dimension is 1.0 to each side). For some reason they tend to think the simulation is too slow, because they're expecting 1.0 to be, perhaps, inches when it is actually meters. In their case the reverse of what I suspect you're observing happens, where ins$$anonymous$$d of the blocks moving like dice on a table, they move like 1 meter boxes on the floor. These students eventually discover how to scale time so the speed of falling looks right to them, but now time is moving too fast for other situations in their work, until they learn to work at more realistic scale.
----------
The physics engine doesn't really "understand" scale, which is to say when you do actively choose to scale objects so, for example, the dimensions of space can fit into the engine's features, one must usually scale time as well. My thinking here is that an orbital balance may require a scale of time, because it may be that gravity vs time ends up crashing into the planet. I need more coffee and time to think, and this is one of those tuning efforts that may require more vision (for those of us trying to help) than snippets might reveal.Sun, 19 Aug 2018 17:22:24 GMTJVene