Download

World Wrap Options

So I have been researching how best to implement World Wrap for a couple days now. I am trying to come up with a list of options with the various pros and cons of each. The math regarding the wrap line is fairly straightforward. How to wrap the world visually is what I am trying to figure out.

First, here are some of the requirements for world wrap implementation:

  1. East and West edges of the tile map need to connect with each other seamlessly:

  1. Tiles on either side of the wrap line must be interactive from either side. IE not just an image of the other side of the world.
  2. AI and movement algorithms need to be able to account for the wrap and traverse it.
  3. An Array with the Vector information for the entire map is stored and should remain intact if at all possible. At least it should be easily updated if required for wrapping.

The options that I have come up with so far:

  1. Level Streaming.
    a. Can the same level be streamed 3 times in 3 different world locations? And do they each retain original vector coordinates if streamed or do they all run off of world space location? If the level can be streamed multiple times and the vectors local to each streamed level, then I could use 3 Levels, all duplicated renders of the map laid out side by side. You start in the middle level and some point after crossing the wrap line in either direction you are teleported back to the middle level. Any action taken on any of the duplicated maps is replicated to the others. Generally only 1-2 of the level would be rendered at a time.
    b. Similar to a. except that the level is continually streamed in ahead of your position. It would be key that the vector information regarding the map be local to the level and not to the world.
    c. ? (I am sure there are more level streaming options as I only have a basic understanding of what you can do with it in UE4)

  2. Great Wall of Portal
    a. Basically a portal spanning from pole to pole and as high as the player’s camera view that would allow both player movement and map interaction from either side of the portal. This is my favorite option, though I am not sure how to do it without camera trickery that might not preserve the ability to interact with tiles through the portal.

  3. ? That is all I can think of that has a chance of working. If you know of a method or have better ways to do the above methods, please let me know, thanks!

Could you not wrap the world around a sphere, and then simply rotate gravity around the player? Granted, you’d need to generate a little more content for it to look good, but it seems like a simple enough solution.

Wrapping it on a cylinder is one option.

One problem is that on my smallest map size(Shown above), I would have to rotate each column of tiles 18 degrees. This could be a real pain to account for visually.

The bigger the map size the better the rotation though. The next biggest map size would be a 9 degree rotation, followed by 6 degrees.

Also, the field of view on the smallest map would be very tight allowing you to use only 1/3 to 1/2 of your screen to show the map. This might be overcome by some camera trickery though I don’t know what is possible with that.

I will play around with this a bit and see how it looks, thanks.

Going to have to do some research on the math required to offset the hex tiles around a cylinder. The rotation was easy enough but lining the hexagons back up as they rotate around isn’t quite as simple.

Yeah even with the offsets the map looks terrible. It would be a crazy amount of work to get the cylinder wrap to work with the rendered tiles given the smaller map sizes. If all maps were 60+ wide(6 degree rotations per column) on the X then I can see it being feasible, but a number of my maps are smaller than that.

So here is what I am going to try and do.

I am going to render my main map like normal. The process I use to determine the Vectors for this map I will use 2 more times with offsets so that I can render a “Shadow” of the map to the east and the west. These Shadows will contain collision volumes and everything just like the main map. All stored indexes will match at all times. Any change to a Shadow updates the single set of arrays that basically run the map.

I will use streaming to keep the loaded maps to a max of 2, but hopefully smaller chunks for the larger maps.

As I scroll further east or west, the player pawn will run into a trigger volume that teleports him to the equivalent position on the main map

The AI won’t care about the Shadows. It will only see the main map and anything that happens or takes place on the main map will replicate to the shadow maps solely for player visuals and interaction.

This setup should be acceptable until I figure out a more elegant way to wrap the world(or such a way is added to the editor/BP).

Here is the Map shadow wrapped:

Just need to work on the streaming and teleport volumes.

Been working on the streaming for a few days now. I can get the sub-levels to load and unload. The tiles spawn when I load. They do not go away when I unload.

I have Child blueprints of my map generator, one for the east and one for the west. When each sub-level is loaded, the child map generators generate their respective side of the map. I have a feeling though that they generate into the persistent level and not into the sub-level that they came from. This means they can’t unload because they are part of the main map. I can see any way to tell the tiles to spawn in any given level. Anyone know?

Until I get a good answer for this or a better way to wrap the world, I will see if I can get the teleportation volumes working which should at least give me a functional world wrap mechanic, even if I can’t unload parts of the world.

Ok, the teleport volume was very easy to create and line up. I now have working world wrap.

Streaming seems to have been a disaster though. If anyone knows how to have procedurally generated content land in a streamed level and not in the persistent level that would be great.