I am making a 4X space game, and scale is an issue.
If you are familliar with Kerbal Space Program (that is unity based), I am after a similar zoom mechanic where you zoom from a single ship all the way out to the full Solar system view (only I want to go even further - to a galactic view)
I am not after a “realistic” scale here, but it has to be large enugh so a nighbour star can not be reached in a reasoble timeframe without special forms of movement.
Currently I have a scale set up where a ship is 1-10 “unity units” a planet is about 200, and moons are placed a few thousand unity units away.
This gives a great view and freedom wihthin this planetary system.
However, allready at a solar scale I will, with this system, run into floating point problems.
Kerbal Space Program is based on unity, and I belive they solve this by keeping the active ship at orgin, and moving everything else; however with this system a change in the active ship results in a reload. I am hoping to avoid that.
Currently I am theorizing some options;
One scene for each planetary system, one scene for each solar system, and one scene for the galaxy view. I have built a “proof of concept” where the scenes change based on zoom and it works oki-ish. Largest issue is the lag and glich on the transient between scenes.
This one requires a fair bit of work, so I come here seeking advice before I start doing it:
Unlike KSP I am (like most other 4X games) on a x-y grid, so in theory I can have layers on my scene separated by ~10000 unity units on the Z axis.When the zoom get near the transient range, I have a second or so to populate the below layer and I then fade into the camera viewing the new layer. This will also act as a transient between a glyph and a more detailed model.
To optimize this I can have a model layer with all sorts of different models, so I will simply move models from this layer and into view.
What do you think; is 2) even an option? Is there a completly different and better way?
No you can’t. Floating point precision errors will slaughter your physics.
Did you checkout Kerball’s Unite presentation? They gave a good overview of the problems of dealing with such huge scales, and go into a fair bit of detail on how they solved the problems. Its a good place to get familiar with the theory.
No, I actually haven’t seen it. Thanks for the tip.
10000 floats have a resolution of about 0.0005. (unless I have done something wrong with maths) I knew I would get into trouble at some point, but I didn’t know that it would break down that soon.
I’ll watch the Unite presentation. And rethink my plan.
The KSP Unite presentation was fantastic. Very inspirational for further progress, and so far the layering inspired from that seems to be very promising.
KSP alow their complex physics to run within 6000 units, and demonstrate minor gliching at 20000 units. I have tested my (much simpler) physics at 40000 units and it works without any noticable faults.
So that physics is “slaugtered” at 10000 units is simply incorrect. I get that it is unreccomennded, so I’ll try avoid it with the KSP tricks, but if I am careful I could do some physics at 10000.
It really depends on your game and your capabilities to be honest.
If your game doesn’t have complex physics, think of Unity as a mere visualization. Use something like doubles or larger internally and then implement a different physics library. Not sure what kind of physics a 4X game would have anyway. This is also how you should go about it anyway if you intend on adding networking to the game.