How to make a looping tilemap (draw node multiple times)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nnnnn

Hello, I want to make it so that when you get to an edge of a tilemap the game will render a copy of the tilemap there.
This should include all the sub nodes like characters on the map. So when the player walks outside the map (into the redrawn map), I can seamlessly teleport the player over to the other side of the map and have a visual illusion of a looping map.

I previously did this in a SDL game by simply recalling the draw map function with an offset position. Can I do something similar in godot? I looked at _draw but couldn’t find a way to redraw the node itself.
I do not want to copy the tilemap node, because all the characters on it have scripts that would run redundantly and probably cause strange behavior and make them desync, ruining the teleport illusion.

If _draw is not the way,
could this realistically be done by drawing to a texture (I suspect that could be slow),
or using multiple cameras (I suspect they would a mess to resize/position)?
Is there maybe an entirely different way to do this in a performant way?

My instict would be to simply move the nodes around, but that seems really slow and hacky

coffeeDragon | 2018-11-26 08:59

Try simply to separate your map from your enemies and store their start position in variables, and then uptade their variables before you need to instantiate new scene - set new scene enemies on to curent scene eneies postition plus offset of the tilemap.
Alternatively, you can try to render your screen with separate viewport on to another texture and offset it to the desired direction and then teleport player (e.g. if it walks to the right of map, teleport it to the left of original tilemap, but center screen on newly created viewport texure).

pospathos | 2018-12-01 20:58