- Home /
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?
2D and 3D are very different problems. A 2D map can tile easily, a 3D map can wrap a sphere (has its own set of problems), or fake that (has another set of problems). What's your specific need?
You cant edit a sphere like a terrain, so I am planning to make it look like a sphere by wrapping it on all sides, and putting a fog particle system by the edge to cover the wrap. How can I do this?
Answer by DaveA · Mar 06, 2011 at 05:27 PM
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 tried that but but its to much work to get everything the same as a normal terrain, I am trying to wrap the map to say, stepping of the edge and getting transported to the other side of a large terrain.
Answer by mightyenigma · May 19, 2011 at 07:27 PM
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 :)
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....?
Answer by mightyenigma · May 19, 2011 at 07:33 PM
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.
Answer by FredrikAK · Jun 08, 2012 at 07:48 PM
If you have Unity Pro, this effect is easily achieved using render to texture
Your answer
![](https://koobas.hobune.stream/wayback/20220613111539im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Positioning Unity Terrain 1 Answer
Changing terrain texture at runtime 1 Answer
Decipher 2 lines of code please 1 Answer
Is there way to see component as code? 0 Answers
Problem With Enemy AI 0 Answers