Wraparound gameplay as if the world is a cylinder?

I’ve been trying to figure out how games like Defender wrap the gameplay and background as if the scene is cylindrical*.

The player is bound to the center of the screen (main camera is parented to the player) so that the world, enemies and projectiles scroll past. As you approach the far right of the scene, you can see into (and pass into) the left side of the scene seamlessly.

What are the basic concepts behind how this works? Is it a multi-camera setup? Any thoughts on how you would set this up in Unity?

*note that “cylindrical” is just an analogy, assume the level is a 2D side scroller with a beginning and an end. What I’m trying to determine is how the beginning and end can be “joined” so that you could travel forward/backward infinitely over the same terrain, seeing the same enemies etc.

I think it depends on what sort of game you have in mind. Would you be using the built-in physics system, or performing collision detection and response yourself? Would the game be 2-d or 3-d? What would the game environment be like? Etc.

Similar to Defender which is a 2D side-scroller where the horizontal world is a finite length. When you reach the end you continue back at the beginning. You can fly in either direction infinately as if navigating the inside of a cylinder.

Also I’m not talking about simply teleporting the player back to the beginning when he reaches the end.

Interesting question… I guess you’re not talking about a cilinder, but a torus (in simple words, a donut). In artificial life simulations is really common to use this system.
Anyway I’m curious to know how to make this in Unity…

Piero

Well, defender was a simple sprites game. They probably had ‘tiles’ of coded artwork, or just one repeating tile. If a ship went off one side it would reappear at the other side.

Seeing how it wasn’t physical art (3d objects), just pixel art it’s probably as simple as code repeat. And the enemies were just teleported, or respawned, whatever.
Since the player never leaves the center the artwork is just scrolling by. It’s not a circle or repeating terrain, or very long.

In fact the player probably never even moves (if I remember you weren’t exactly fixed to center but ‘floated’ depending on if you are speeding up, slowing down, turning around).

You could probably do the same, even with 3d art, just have 1 large tile, then scroll it past player (player controls scroll the terrain, player doesn’t move sideways) and instantiate a tile when the player nears the end (so it’s seamless) and destroy the tile that leaves the screen.


Or you could have a 3d cylinder, and just spin it with foward backward controls.

A simple way to do it is to have “clone” objects offset by the length of the world. If you were doing a Defender game, for example, and the length of the world was 300 units, then all objects except the player would have “clones” at their transform.position.x+300 and transform.position.x-300. The “clones” are mesh renderers only that duplicate the original, but don’t have colliders or anything. When any object goes past the beginning or end, it’s teleported +300 or -300 units as needed. The background should wrap seamlessly, and extend beyond the world edges far enough so the teleporting isn’t visible (this is how the scrolling background in Tank Zone works).

I imagine it’s also possible to handle it with two cameras instead, and alter the viewports as necessary when the player approaches the beginning/end of the world. This would be a little harder to figure out, but would probably be easier than the clone thing if you have a complex world.

–Eric