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 :)
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.
answered Feb 24 '10 at 10:29 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
answered Feb 24 '10 at 10:26 PM
You can set the mass of a rigidbody to anything you want in a script. eg.
answered Jun 15 '10 at 06:43 AM