# How to handle movements of objects in a platformer with a cylindrical map?

I was wondering what would be the best approach for a game with a perspective like Resogun, where the world wraps around in a cylinder:

In my opinion, the easiest approach is to:

• have a "Center Parent" for each moving object

• Offset the child object by the wanted radius

• Rotate the parent

=> The objects will move, though this will become super limited very quickly, especially if you want to do any sort of physics.

The 2nd approach is math:

x = centerX + cos(angle)*radius;


Now i wonder if there is another way, I was thinking of another method which basically consist of changing the Forward direction of the moving objects based on their position in "the circle", so basically the objects always move forward but adjust their rotation according to their position so they are always facing the right angle.

My main question is that if you want to create a puzzle platformer game like Limbo for example, but in a "cylindrical" map like Resogun, how would you tackle it ?

Thanks!

One way is to internally handle everything in 2D, and remap the x-coordinate into a cylindrical space for your graphics.

Here's a very simple example. Attach this to an object that moves in 2D space to have it move a corresponding mesh renderer in cylinder space.

public class CylinderSpaceObject : MonoBehaviour {
[SerializeField] private Transform cylinderCenter;
[SerializeField] private float cylinderRadius = 5;
[SerializeField] private GameObject renderer;

void LateUpdate() {

//convert rotation to cylinder space

//convert position to cylinder space
//note we negate the value here so positive x values move counter-clockwise
//we also add 90 degrees so our renderer is towards the camera when x = 0
var offset = new Vector3(x, transform.localPosition.y, z);
renderer.transform.position = cylinderCenter.position + offset;
}


Using this approach, all of your gameplay components (such as rigidbodies, colliders, etc) would be attached to the GameObject that has the CylinderSpaceObject component. The renderer would be a separate GameObject containing only rendering components.