So out on the left and back in on the right

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

A week ago I started to deal with the topic of creating/scripting in general.
As my first project, I considered a universe game for Android and immediately encountered a problem.
How do I script that the player reappears on the other side when it leaves the left or right edge of the screen.
So out on the left and back in on the right.
Do I do that with a body_exited?
How do I write this best, hope you can help me.
Thanks in advance.

:bust_in_silhouette: Reply From: Wakatta

This is as simple as it gets.
You can also use wrapf to specify the ranges

func _process(delta):
    global_position.x = posmod(global_position.x +2, get_viewport_rect().size.x)