Curving Dimensions (or similuating 4 dimensions of space)

Hey All,

I’m creating a 3d space-game. I need a way to wrap space around itself. Here’s the idea:

The universe I made now is a perfect cube (let’s say 500 by 500) when your spaceship exceeds one edge of the universe (say, x = 501), it is automatically placed in the other side (x = -500), preserving orientation and velocity. This is great except for one huge problem:

The camera is a child of the space ship. When the camera is toward the edge of the universe looking outward, it sees nothing but empty space. Then, the moment it warps around, it sees all sorts of content instantly pop into view. Observe:

= spaceship facing right
X = content
| = universe border

|XXXXXXX>XXXXXX| ship is in the middle of the universe and sees content in the direction its facing
|XXXXXXXXXXXXX>| ship approaches edge of the universe and sees no content
|>XXXXXXXXXXXXX| ship warps around and suddenly sees tons of content

Though the programming is smooth, the visual experience is actually really disorienting. The easy way to solve this problem in two dimensions would be to use the third dimension: For example, I could make a 2d character run towards the right around a pole on the y-axis and film it in such a way that the 2d character looks like he’s running in one straight line, but he actually winds up where he started.

Does anyone have any ideas of how I could do this in three dimensions?

Before anyone talks about simulating this, yes, I’ve thought about using multiple cameras. There are some serious problems with that (specifically, that solution would only work on one axis and only if the camera is facing the same way the ship is moving). Also, it can only simulate what it is that I’m really trying to do. I’ve also thought of warping the universe around the player instead, but as I intend to make this a multi-player game, that can’t work (there would also be a lot of processor problems). Any thoughts?

Thanks,
Vincent

render texture could work, with a clone of the ship at the wrapped point for logic.

Render Texture? Could you explain further how that would work? Thanks.

Edit: Also, that’s Unity Pro only. Any way I could get this done for free? Does everyone understand the problem?

You’d render what your camera should see on the other side of the edge, and paint that onto a plane using Extreme Maths For Finding Out Where Its Corners Are And Stuff.

In Unity Free, I think you’ll need to do something like this:

class SpaceObject extends MonoBehaviour  {
  var clones : Transform[];
  function Start() {
    clones = CreateClones(); // creates graphical clones of this object (no logic, just pretty pictures)
  }

  function Update() {
    clones[0].position = transform.position + Vector3.up * space.y;
    clones[1].position = transform.position - Vector3.up * space.y;
    clones[2].position = transform.position + Vector3.right * space.x;
    clones[3].position = transform.position - Vector3.right * space.x;
    clones[4].position = transform.position + Vector3.forward * space.z;
    clones[5].position = transform.position - Vector3.forward * space.z;
  }
}

You can optimize this (for example by skipping invisible objects), but that’s how I’d start it off.

Thanks. I actually thought of this. If I understand you correctly, though, there’s one huge problem:

It looks like you’ve covered the six sides of a cube; up, down, left, right, forward, and backward. The problem is, this doesn’t cover edges of the cube or corners of the cube. In order to cover those possibilities, I’d need a whopping 3 * 3 * 3 - 1(original) = 26 clones of every object! And as there can be a few hundred asteroids floating around, this doesn’t seem likely possible.

Did I understand you correctly? Are there any other ideas?