Is there a way to make a scene loop?

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

So basically if your character exits in the left they appear in the right.

I know ofc you can make a somewhat similair effect by simply changing their position, but it’s not really looping since if you’re standing right at the border, instead of half the character appearing in the left and the other in the right, you’ll only be on one side.

:bust_in_silhouette: Reply From: flurick

This could be done with 9 cameras render on top of each other in a 3x3 grid but I would have to look into the details of alphamasks or maybe a shader.

But if you only want one simple sprite to render on the opposite screen edge this would work:

func _process(delta):
	...
	update()

func _draw():
	var rect_center = get_rect().size*0.5 
	var view = get_viewport().size
	draw_texture(texture, Vector2( view.x, 0) - rect_center )
	draw_texture(texture, Vector2(-view.x, 0) - rect_center )
	
	

Unfortunately not. It’s a KinematicBody with more than one sprite attached.

MOSN | 2019-03-19 18:20

Could you explain the 3x3 grid idea? I suppose that it would work in the way that if your character for example exits the bottom left cameras view to the left, that part will be drawn in right of the bottom right camera. But I don’t know how to actually do this.

MOSN | 2019-03-22 16:07