Search Unity

Problem simulating tiny ships vs huge stations and planets

Discussion in 'iOS and tvOS' started by swiftest, Sep 5, 2010.

  1. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    We are building a space game where ships are tiny in relation to space stations and planets. Think Elite or Eve Online. We want to maintain realistic scales. If we use 1 pixel == 1 meter, we run into a bunch of issues: the camera view distance is limited to somewhere north of 50,000 which means big planets or even stations have "pop up". Also, the really big ships seem to have issues with the physics engine, and they also seem to create slowdowns whereas before when all ships were roughly the same small size, there wasn't a performance issue.

    We're going to try to reduce the size of all models by 100x so that 1 pixel == 100 meters. Does this seem like a reasonable compromise? Has anyone else attempted this or is this beyond Unity iPhone? Are there any hidden physics or graphical gotchas that we should be aware of at this scale?

    Also, we bought "regular-sized" ship and station models and have to scale them up or down. So is it better to change the ship model scale at the import dialog or via the object's scale property after import? Or do we need to scale it in a 3D modeling program to be safe?

    Anyway, we have most other aspects of the game coded, and hope to launch in the app store in about a month, so we'd definitely appreciate any advice or pointers.

    Thanks,
    Linh
     
  2. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    It's very confusing to talk in pixels as it suggests you are talking about an image as opposed to a model. When you say 10m = 1pixel what does that mean? Do you mean 10m in game world = 1m in Unity Engine?

    I don't know about physics slowdowns with massively scaled models but certainly physics will be altered by changing the scale. That said the effect is primarily on bouncing, falling, and other physical phenomena that wont play much of a role in a space game.
     
  3. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Sorry, I meant the coordinate system, not pixel. An object at (1,0,0) is 1 unit away from (2,0,0). In our game, 1 unit = 1 meter.

    I did some import scaling tests on the ship models and 10x reduction in the mesh size (0.1) seems to work, but 100x (0.01) reduction causes some models to vanish.

    At any rate, our goal is to more realistically show the ship space station against the backdrop of, say, the Earth. Using Google, I come up with the following diameter measurements:

    Earth: 12,715 km
    Jupiter: 142,984 km

    We have the camera's far clip plane set at the roughly max value of 60000. That equals only 60km, far less than can show the earth.

    So to get the Earth into this view, we'd have to set the far clip plane to 12715000 units which is 12715 km / 60 km = 212x larger. However, going beyond 60000 in the far clip plane causes severe tearing and other graphical issues. So we have to keep the far clip plane at 60000, but scale our ship models down by 212x. However, scaling ship polygon models down by 100x causes some of them to disappear. So complete realism is quite difficult without some other approximation method. (Not to mention having planets like Jupiter or even the Sun.)

    I have also considered creating a flat circular polygon that could approximate the "size" of the Earth and forcing it to stay orthogonal to the camera. If it barely moves except when warping around, it would be convincing. But this is more complicated and requires way more time than we have to implement.

    So at this point, there doesn't seem to be an easy fix. I think we'll save it for a future upgrade if our game does well. But if anybody has ideas, we'd love to hear 'em. :)

    Thanks,
    Linh
     
  4. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    You're never gonna get complete realism and real world scaling. You'd hit that fp error before you reached the Moon. Also physics objects of hugely different scales are well known not to work so well together.

    You'll have to try other methods or continue to face these issues. And before you throw Eve out there as a "well they did it", they like others, faked it.
     
  5. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Anybody have any ideas on how to fake it?

    One idea I had was to create a circular flat polygon to represent a planet and make it always face the camera. Then figure out the apparent size using some fancy math to scale it depending on how far away it is from your ship. The difficulty would be to make sure no ships could go "behind" it, and that it would grow or shrink infinitesimally as you moved toward or away from it. Any thoughts on how I would implement such a scheme? Scaling doesn't seem hard, but is there a camera mode that always keeps the image behind everything else?

    I suppose it could even be done with a real textured lighted sphere as long as you reposition it every frame and make sure it renders behind everything.
     
  6. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Using the camera depth settings and layer masking will accomplish this. You may need a second camera set up for just the planet.

    HTH
    BTH
     
  7. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Thanks, Bluster. I'll look into that.