Cube for a World Question

I was throwing around a few game ideas with my friend when he came up with something interesting, yet stumping. The idea is that the player walks on a cube world (like Monty Python’s The Meaning of Life - not a sphere :smile:). The only difference is that, instead of falling off when reaching the edge of the top surface, the character rotates so he can stand the next surface (e.g. back). Thus, if he continued walking, he would eventually return to the first surface (top-back-bottom-front-top). The idea is that we can, to an extent, have 6 different maps, yet interconnected on the same world.

Off hand, I don’t know how to program such a behavior. Does anyone have suggestions either how to go about this or something similar to learn from? I’d assume the only options are to have a) the character’s personal gravity change so he goes around the cube, or b) have the cube rotate around the character, while he remains at one point.

I think the best way would be to have the characters gravity change relative to the cube. I suggest turning off the gravity flag in the rigidbody component, and add a “gravity” component that updates gravity accordingly. For direction, normally with a sphere you would just do “(spherePos - characterPos).normalized”, but that would make you slide towards the center of each face.

For a cube, you’ll want to check if the player is above a given surface (for example: if (pos.x > worldCenter.x + worldHalfWidth player.withinBounds(yz) gravityVector = new Vector3(-1, 0, 0); ), and if it isn’t (either you’re going over an edge or corner) you’ll want to update based on that edge/corner.

Here’s a picture, it might be easier to understand.

Definitely an interesting approach, and the visual really helped. I’ll have to try and test the mechanic out this weekend.