How to handle seamless wrap around levels?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zyrixian
:warning: Old Version Published before Godot 3 was released.

So apparently this is harder to do then i thought it would be.

I’m trying to seamlessly wrap my level around x & y.
So once the player gets to (3000,500) they will then end up back at (0,500)

I originally was just going to have the player object do a set_pos() once it got outside that coord, however i’m realizing now that the player needs to see the objects past the wraparound point before he crosses it. It can’t be a sudden jump like i was originally thinking. Is something like this even possible in GODOT? And if so, how would one go about doing it?

–EDIT–
I probably should have mentioned it’s going to be multiplayer

:bust_in_silhouette: Reply From: JESTERRRRRR

I’m thinking you will need to have 2 copies of your ‘level’, placed side by side (assuming its scrolling sideways?), and once your character passes a certain threshold (at which point the first level can no longer be seen) remove it. Or you could just make the original level partially looped itself (e.g. it has a small part of the beggining (x=0) tacked on at the end (x=3000) and once you move far enough so you cannot see behind x=0, you then do the warp and it won’t appear sudden (though everything else needs to be warped too).

Thanks, I had heard this idea before, but i’m not sure how that will work if it’s multiplayer. I guess you would just have to have the player object and the mirrored objects move in sync. That just seems like a really clunky way of doing it.

zyrixian | 2017-02-21 17:55

:bust_in_silhouette: Reply From: Benedikt Bär

Maybe you could break your level up into a set of pieces, say 3, or 6, (or choose whatever makes sense for it).

Then, as the player moves across the level you “add” the pieces to the end of the level the player is on, and remove levels at the beginning as the viewport moves.

I was going to say this too, and don’t remove the parts, just move them, add triggers, when enter the screen, move the sections to the corresponding place.

Maybe you can use a Node2D as root of the sections and keep reparenting them on the same relative positions.


Some solutions may work better or worse, depending on your design.

This one, for example, may require objects and enemies restricted to a level section.

eons | 2017-02-21 13:30