0 votes

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.

Godot version Standard 64
in Engine by (12 points)

1 Answer

0 votes

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)
by (5,776 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.