It’s been a while since I’ve touched Unity; mostly because work has been rough and my desire for non-work coding has been nonexistent. But I’ve been toying with some ideas and I wanted to actually try doing something new, so I downloaded some updates, cracked open Unity, and started a new project.
My close friends know how absurdly crazy I am about space in general. On top of that, I’ve been wanting to use some “real” math again (business applications rarely involve much math). So on Friday, after talking with a coworker a bit, I decided I was going to program a solar system simulator this weekend. And while the result isn’t exactly what I wanted, it works and it’s something I can expand on.
To start, I knew I’d need something to generate pretty planets, and I recently saw a planet kit advertised on Unity’s Twitter feed. It does a good job in general, even with the free version of Unity. There are several places where some more advanced effects don’t work (thunderstorms on planets, city lights at night, and the lighting quality in general in a few places), but from what I can tell, it’s just because I can’t use Unity’s deferred lighting mode. The stars in particular don’t look as great as they could. After getting the new planets imported, I set up a quick PlayMaker script to generate a simple solar system.

When I say “simple solar system”, I mean just that: a random number of planets, with a random number of moons orbiting at random angles and rates. Took all of an hour. I didn’t even have to program orbits – the planet kit I bought actually has a script that makes planets and moons orbit. Not realistically, but it’s something, at least.

My next goal is to write a more complicated generation script that’ll generate a more realistic system, and some new code to handle orbits more realistically. After doing a little reading on how Kerbal Space Program implemented orbital mechanics (patched conic approximation), I’ll probably start with something similar since that’s a much simpler model. I’ll also take some time to read the entire Wikipedia entry on orbital mechanics and see if I can recall some trigonometry.

