Wrapping A Game Map..

When I get to the end of a map, how do I get it to wrap around on all side making a spherical illusion?

I've not tried this, but you could see if it works for you: make your terrain, then make 8 more copies of it to surround your original which is in the middle. Then limit movement (colliders I would think) to stay inside that middle tile, but they could see the edges of the other tiles. You'd of course have to edit the terrain itself so the edges match up smoothly. To get them to 'wrap' (if they keep moving to the right, they'll be tossed back to the left) you'd need to set the player transform.position to the other side of the tile. You might also use a collider (OnEnter) to detect that the player has entered and do this to 'teleport' him back to the other side.

I have gotten this to work in UDK using portals. I don’t know if Unity has portals or not. It would be FAR better if you could define the world size and the engine would just wrap the transform of all actors crossing the boundaries.

One note though: this is not spherical behavior. If you run off the north end of a true sphere, you would come back on the north edge, but your east/west position would be mirrored, and your north-south orientation would be flipped.

The usual behavior in RPG world maps that wrap around a square is more like you’re on the surface of a donut/torus. This means if you run off the north end you come back on the south. It’s very intuitive, player-friendly, and easier to implement, but not geographically correct if you’re representing a world globe :slight_smile:

In my opinion, though, player-friendliness is more important than realism, and often easier to implement.

I came over here looking to see if Unity could do what UDK does not, that is, wrap the world boundaries.

I had the same idea as you guys earlier with making 8 adjacent duplicates of the terrain. However, our game requires other things to be moving around the world and crossing over the wrap boundaries. Just duplicating the terrain and having the objects pop over to the other side would result in a lot of cases where other guys seem to disappear from in front of you if you chase them across the boundary. Not cool.

See if Unity has world boundary wrapping of some kind, and if not, see if it has portals. I’ve gotten the portal thing to work in UDK, but it’s got issues near the corners where the portals touch. Maybe it’s because I’m letting them overlap…?

wrapping a world to a donut or sphere is NOT high tech. It’s been around for height maps (terrain) since 1985 at least (Rescue on Fractalus).

I thought about why these high-end game engines can’t do it, and I think the answer is that all the stuff that’s been built around the core is so dependent on the paradigm of a first-person shooter taking place in rooms, that you’d have to redesign the engine almost from the ground up for all the dev kit stuff to work with the wraparound capability. Hopefully this is not the case, as it’s a relatively simple feature to implement if you were creating your own engine from scratch.

If you have Unity Pro, this effect is easily achieved using render to texture