- Home /
Very big numbers (size, mass, etc), Scientific Notation
Hello,
I'm currently learning my way aroudn Unity and the scripting languages and as an exercise, i'm making a little demo application where you can control a spaceship orbiting a planet. I was wondering if it is possible to use a realistic scale?
Size isn't too much of an issue, as the Earth has a radius of 6000km, and i can set the (currently spherical, as I haven't done any modelling yet!) spaceship to have a radius of 1km.
However, the mass of the earth is ~6x10^24, and I'm having trouble working out how to specify this? RigidBody's seem to have a maximum mass of 10000 units? (although as I've done my own gravity model, I can use my own mass value in a script easily enough). I also need to specify the gravitational constant, G=6.7x10^-11.
Obviously, I don't have to use real units, and from a gameplay perspective, realistic scales might not be a lot of fun. But i'm trying to simulate this as a learning exercise, so I might as well try and be as accurate as the engine allows me to be! And watching a satellite trace out elliptical orbits is quite satisfying!
I assume that trying to make planets orbit the sun will be outside the scope of the Unity Engine (even Sins of a Solar Empire shys away from tackling this)... and I assume, if I wanted to pursue this as a game idea, the sensible appraoch would be to use two scales... a solar-system map, and then "planetary orbit" scale for actually flying ships around.
It would be interesting to see what the scale limits are for Unity though :)
Thankyou!
Answer by Eric5h5 · Feb 24, 2010 at 10:29 PM
It's not really possible to use realistic units for such large scales. Unity uses single-precision floating point for the position of objects, which creates precision problems the farther away you get from the origin. For typical usage this isn't a problem, but using the kind of scale you need for planetary distances isn't feasible.
In any case, the mass is arbitrary. It's only relevant compared to other objects, so you can define the mass of Earth as 1, for example.
Thanks for the answers... I'll give that forum thread a read at some point.
The good news: As I can't use realistic parameters, I guess my little Earth orbit sim is now complete :) [Just now i've set things up so it feels/looks right rather than being realistic!]
Shame I can't use double-precision though
Guess I now have to think up a new little exercise to work on :)
Answer by Sebas · Feb 24, 2010 at 10:26 PM
There is the perfect thread for you on the forums. HiggyB put together a physics simulation of the inner planets of our solar system, but I think the only way to make this work is by scaling down A LOT. Check this forum thread and a demo of Higgy's orbitsim
The links are both broken but this forum post still works and has references to the source file: http://forum.unity3d.com/threads/unity-able-to-manage-full-scale-stellar-systems.38782/
Answer by Tom 5 · Jun 15, 2010 at 06:43 AM
You can set the mass of a rigidbody to anything you want in a script. eg.
public float mass = 6e24f;
void Start() { rigidbody.mass = mass; }
Your answer
![](https://koobas.hobune.stream/wayback/20220612083624im_/https://answers.unity.com/themes/thub/images/avi.jpg)